{"record":{"id":"695a16e8004d63e9","repo":"tensorflow/models","slug":"only-call-run-customized-training-loop-with-na","errorCode":null,"errorMessage":"only call `run_customized_training_loop()` with named arguments.","messagePattern":"only call `run_customized_training_loop\\(\\)` with named arguments\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/bert/model_training_utils.py","lineNumber":218,"sourceCode":"      allreduce_bytes_per_pack: A non-negative integer. Breaks collective\n        operations into packs of certain size. If it's zero, all gradients are\n        in one pack. Breaking gradient into packs could enable overlap between\n        allreduce and backprop computation. This flag only takes effect when\n        explicit_allreduce is set to True.'\n\n  Returns:\n      Trained model.\n\n  Raises:\n      ValueError: (1) When model returned by `model_fn` does not have optimizer\n        attribute or when required parameters are set to none. (2) eval args are\n        not specified correctly. (3) metric_fn must be a callable if specified.\n        (4) sub_model_checkpoint_name is specified, but `sub_model` returned\n        by `model_fn` is None.\n  \"\"\"\n\n  if _sentinel is not None:\n    raise ValueError('only call `run_customized_training_loop()` '\n                     'with named arguments.')\n\n  required_arguments = [\n      strategy, model_fn, loss_fn, model_dir, steps_per_epoch, train_input_fn\n  ]\n\n  steps_between_evals = int(steps_per_epoch / num_eval_per_epoch)  # pyrefly: ignore[unsupported-operation]\n  if [arg for arg in required_arguments if arg is None]:\n    raise ValueError('`strategy`, `model_fn`, `loss_fn`, `model_dir`, '\n                     '`steps_per_epoch` and `train_input_fn` are required '\n                     'parameters.')\n  if not steps_per_loop:\n    if tf.config.list_logical_devices('TPU'):\n      # One can't fully utilize a TPU with steps_per_loop=1, so in this case\n      # default users to a more useful value.\n      steps_per_loop = min(1000, steps_between_evals)\n    else:\n      steps_per_loop = 1","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/bert/model_training_utils.py#L200-L236","documentation":"Error \"only call `run_customized_training_loop()` with named arguments.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/bert/model_training_utils.py:218 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"}