class_docstr: Handles training restarts.
  
  Particularly useful when sharing parameters (and checkpoints) between models.
  
  Args:
    model_mode (str): Model "mode". Different modes have different local step
        counters, but the same global step counter. Also used in log messages.
    checkpoint_dir (str): Model checkpoint directory. Global step is inferred
        from the name of the last checkpoint.
    target_local_step (int): Local step to train the model up to.
  
  Attributes:
    model_mode (str): See args.
    checkpoint_dir (str): See args.
    target_local_step (int): See args.
    target_global_step (int): Calculated global step to train the model up to.
    should_skip (bool): Whether training should be skipped because the number of
        local steps already done is higher than the target. This happens during
        restarts.
    steps_to_go: how many steps to go.
    restarting (bool): Whether the current epoch of training has been
        interrupted and is being restarted.
docstr: Context manager wrapping the training loop, updates step counters.
code: def training_loop(self):
      """Context manager wrapping the training loop, updates step counters."""
      if not self.restarting:
          self._write_counters(
              self._local_step_at_start, self._global_step
          )
  
      tf.logging.info(
          "Training %s up to %d, %d to go",
          self.model_mode,
          self.target_local_step,
          self.steps_to_go,
      )
  
      yield
  
      self._write_counters(self.target_local_step, -1)
  
file_path: tensor2tensor/tensor2tensor/rl/restarter.py
imports: import contextlib
  import os
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the Restarter obj's underlying member method code with example usage: obj.training_loop() without return types