class_docstr: Base class of trainer.
  
  Use trainer.setup(algo, env) to setup algorithm and environment for trainer
  and trainer.train() to start training.
  
  Args:
      snapshot_config (garage.experiment.SnapshotConfig): The snapshot
          configuration used by Trainer to create the snapshotter.
          If None, it will create one with default settings.
  
  Note:
      For the use of any TensorFlow environments, policies and algorithms,
      please use TFTrainer().
  
  Examples:
      | # to train
      | trainer = Trainer()
      | env = Env(...)
      | policy = Policy(...)
      | algo = Algo(
      |         env=env,
      |         policy=policy,
      |         ...)
      | trainer.setup(algo, env)
      | trainer.train(n_epochs=100, batch_size=4000)
  
      | # to resume immediately.
      | trainer = Trainer()
      | trainer.restore(resume_from_dir)
      | trainer.resume()
  
      | # to resume with modified training arguments.
      | trainer = Trainer()
      | trainer.restore(resume_from_dir)
      | trainer.resume(n_epochs=20)
docstr: Step through each epoch.
  
  This function returns a magic generator. When iterated through, this
  generator automatically performs services such as snapshotting and log
  management. It is used inside train() in each algorithm.
  
  The generator initializes two variables: `self.step_itr` and
  `self.step_episode`. To use the generator, these two have to be
  updated manually in each epoch, as the example shows below.
  
  Yields:
      int: The next training epoch.
  
  Examples:
      for epoch in trainer.step_epochs():
          trainer.step_episode = trainer.obtain_samples(...)
          self.train_once(...)
          trainer.step_itr += 1
docstr_tok: ["Step","through","each","epoch",".","This","function","returns","a","magic","generator",".","When","iterated","through",",","this","generator","automatically","performs","services","such","as","snapshotting","and","log","management",".","It","is","used","inside","train","(",")","in","each","algorithm",".","The","generator","initializes","two","variables",":","`","self.step_itr","`","and","`","self.step_episode","`",".","To","use","the","generator",",","these","two","have","to","be","updated","manually","in","each","epoch",",","as","the","example","shows","below",".","Yields",":","int",":","The","next","training","epoch",".","Examples",":","for","epoch","in","trainer.step_epochs","(",")",":","trainer.step_episode","=","trainer.obtain_samples","(","...",")","self.train_once","(","...",")","trainer.step_itr","+=","1"]
code: def step_epochs(self):
      """Step through each epoch.
  
      This function returns a magic generator. When iterated through, this
      generator automatically performs services such as snapshotting and log
      management. It is used inside train() in each algorithm.
  
      The generator initializes two variables: `self.step_itr` and
      `self.step_episode`. To use the generator, these two have to be
      updated manually in each epoch, as the example shows below.
  
      Yields:
          int: The next training epoch.
  
      Examples:
          for epoch in trainer.step_epochs():
              trainer.step_episode = trainer.obtain_samples(...)
              self.train_once(...)
              trainer.step_itr += 1
  
      """
      self._start_time = time.time()
      self.step_itr = self._stats.total_itr
      self.step_episode = None
  
      # Used by integration tests to ensure examples can run one epoch.
      n_epochs = int(
          os.environ.get(
              "GARAGE_EXAMPLE_TEST_N_EPOCHS", self._train_args.n_epochs
          )
      )
  
      logger.log("Obtaining samples...")
  
      for epoch in range(self._train_args.start_epoch, n_epochs):
          self._itr_start_time = time.time()
          with logger.prefix("epoch #%d | " % epoch):
              yield epoch
              save_episode = (
                  self.step_episode
                  if self._train_args.store_episodes
                  else None
              )
  
              self._stats.last_episode = save_episode
              self._stats.total_epoch = epoch
              self._stats.total_itr = self.step_itr
  
              self.save(epoch)
  
              if self.enable_logging:
                  self.log_diagnostics(self._train_args.pause_for_plot)
                  logger.dump_all(self.step_itr)
                  tabular.clear()
  
imports: import copy
  import os
  import time
  import cloudpickle
  from dowel import logger, tabular
  from garage.experiment.deterministic import get_seed, set_seed
  from garage.experiment.experiment import dump_json
  from garage.experiment.snapshotter import Snapshotter
label_desc: Use image node_id 11 for calling the Trainer obj's underlying member method code with example usage: obj.step_epochs() without return types