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: Restore experiment from snapshot.
  
  Args:
      from_dir (str): Directory of the pickle file
          to resume experiment from.
      from_epoch (str or int): The epoch to restore from.
          Can be 'first', 'last' or a number.
          Not applicable when snapshot_mode='last'.
  
  Returns:
      TrainArgs: Arguments for train().
docstr_tok: ["Restore","experiment","from","snapshot",".","Args",":","from_dir","(","str",")",":","Directory","of","the","pickle","file","to","resume","experiment","from",".","from_epoch","(","str","or","int",")",":","The","epoch","to","restore","from",".","Can","be","'first","'",",","'last","'","or","a","number",".","Not","applicable","when","snapshot_mode='last","'",".","Returns",":","TrainArgs",":","Arguments","for","train","(",")","."]
code: def restore(self, from_dir, from_epoch="last"):
      """Restore experiment from snapshot.
  
      Args:
          from_dir (str): Directory of the pickle file
              to resume experiment from.
          from_epoch (str or int): The epoch to restore from.
              Can be 'first', 'last' or a number.
              Not applicable when snapshot_mode='last'.
  
      Returns:
          TrainArgs: Arguments for train().
  
      """
      saved = self._snapshotter.load(from_dir, from_epoch)
  
      self._seed = saved["seed"]
      self._train_args = saved["train_args"]
      self._stats = saved["stats"]
  
      set_seed(self._seed)
  
      self.setup(env=saved["env"], algo=saved["algo"])
  
      n_epochs = self._train_args.n_epochs
      last_epoch = self._stats.total_epoch
      last_itr = self._stats.total_itr
      total_env_steps = self._stats.total_env_steps
      batch_size = self._train_args.batch_size
      store_episodes = self._train_args.store_episodes
      pause_for_plot = self._train_args.pause_for_plot
  
      fmt = "{:<20} {:<15}"
      logger.log(
          "Restore from snapshot saved in %s"
          % self._snapshotter.snapshot_dir
      )
      logger.log(fmt.format("-- Train Args --", "-- Value --"))
      logger.log(fmt.format("n_epochs", n_epochs))
      logger.log(fmt.format("last_epoch", last_epoch))
      logger.log(fmt.format("batch_size", batch_size))
      logger.log(fmt.format("store_episodes", store_episodes))
      logger.log(fmt.format("pause_for_plot", pause_for_plot))
      logger.log(fmt.format("-- Stats --", "-- Value --"))
      logger.log(fmt.format("last_itr", last_itr))
      logger.log(fmt.format("total_env_steps", total_env_steps))
  
      self._train_args.start_epoch = last_epoch + 1
      return copy.copy(self._train_args)
  
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 8 for calling the Trainer obj's underlying member method code with example usage: obj.restore(from_dir, from_epoch) and returns: copy