{"record":{"id":"1724d3700f7961c2","repo":"tensorflow/models","slug":"eval-step-is-required-when-eval-input-fn-is-n","errorCode":null,"errorMessage":"`eval_step` is required when `eval_input_fn ` is not none.","messagePattern":"`eval_step` is required when `eval_input_fn ` is not none\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/bert/model_training_utils.py","lineNumber":256,"sourceCode":"                 steps_per_loop)\n  if steps_per_loop > steps_between_evals:\n    logging.warning(\n        'steps_per_loop: %d is specified to be greater than '\n        ' steps_between_evals: %d, we will use steps_between_evals as'\n        ' steps_per_loop.', steps_per_loop, steps_between_evals)\n    steps_per_loop = steps_between_evals\n  assert tf.executing_eagerly()\n\n  if run_eagerly:\n    if isinstance(\n        strategy,\n        (tf.distribute.TPUStrategy, tf.distribute.experimental.TPUStrategy)):\n      raise ValueError(\n          'TPUStrategy should not run eagerly as it heavily relies on graph'\n          ' optimization for the distributed system.')\n\n  if eval_input_fn and eval_steps is None:\n    raise ValueError(\n        '`eval_step` is required when `eval_input_fn ` is not none.')\n  if metric_fn and not callable(metric_fn):\n    raise ValueError(\n        'if `metric_fn` is specified, metric_fn must be a callable.')\n\n  total_training_steps = steps_per_epoch * epochs  # pyrefly: ignore[unsupported-operation]\n  train_iterator = _get_input_iterator(train_input_fn, strategy)\n  eval_loss_metric = tf_keras.metrics.Mean('training_loss', dtype=tf.float32)\n\n  with distribute_utils.get_strategy_scope(strategy):\n    # To correctly place the model weights on accelerators,\n    # model and optimizer should be created in scope.\n    model, sub_model = model_fn()  # pyrefly: ignore[not-callable]\n    if not hasattr(model, 'optimizer'):\n      raise ValueError('User should set optimizer attribute to model '\n                       'inside `model_fn`.')\n    if sub_model_export_name and sub_model is None:\n      raise ValueError('sub_model_export_name is specified as %s, but '","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/bert/model_training_utils.py#L238-L274","documentation":"Error \"`eval_step` is required when `eval_input_fn ` is not none.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/bert/model_training_utils.py:256 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}