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: Start training.
  
  Args:
      n_epochs (int): Number of epochs.
      batch_size (int or None): Number of environment steps in one batch.
      plot (bool): Visualize an episode from the policy after each epoch.
      store_episodes (bool): Save episodes in snapshot.
      pause_for_plot (bool): Pause for plot.
  
  Raises:
      NotSetupError: If train() is called before setup().
  
  Returns:
      float: The average return in last epoch cycle.
docstr_tok: ["Start","training",".","Args",":","n_epochs","(","int",")",":","Number","of","epochs",".","batch_size","(","int","or","None",")",":","Number","of","environment","steps","in","one","batch",".","plot","(","bool",")",":","Visualize","an","episode","from","the","policy","after","each","epoch",".","store_episodes","(","bool",")",":","Save","episodes","in","snapshot",".","pause_for_plot","(","bool",")",":","Pause","for","plot",".","Raises",":","NotSetupError",":","If","train","(",")","is","called","before","setup","(",")",".","Returns",":","float",":","The","average","return","in","last","epoch","cycle","."]
code: def train(
      self,
      n_epochs,
      batch_size=None,
      plot=False,
      store_episodes=False,
      pause_for_plot=False,
  ):
      """Start training.
  
      Args:
          n_epochs (int): Number of epochs.
          batch_size (int or None): Number of environment steps in one batch.
          plot (bool): Visualize an episode from the policy after each epoch.
          store_episodes (bool): Save episodes in snapshot.
          pause_for_plot (bool): Pause for plot.
  
      Raises:
          NotSetupError: If train() is called before setup().
  
      Returns:
          float: The average return in last epoch cycle.
  
      """
      if not self._has_setup:
          raise NotSetupError(
              "Use setup() to setup trainer before training."
          )
  
      # Save arguments for restore
      self._train_args = TrainArgs(
          n_epochs=n_epochs,
          batch_size=batch_size,
          plot=plot,
          store_episodes=store_episodes,
          pause_for_plot=pause_for_plot,
          start_epoch=0,
      )
  
      self._plot = plot
      self._start_worker()
  
      log_dir = self._snapshotter.snapshot_dir
      summary_file = os.path.join(log_dir, "experiment.json")
      dump_json(summary_file, self)
  
      average_return = self._algo.train(self)
      self._shutdown_worker()
  
      return average_return
  
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 10 for calling the Trainer obj's underlying member method code with example usage: obj.train(n_epochs, batch_size, plot, store_episodes, pause_for_plot) and returns: average_return