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: Set up trainer for algorithm and environment.
  
  This method saves algo and env within trainer and creates a sampler.
  
  Note:
      After setup() is called all variables in session should have been
      initialized. setup() respects existing values in session so
      policy weights can be loaded before setup().
  
  Args:
      algo (RLAlgorithm): An algorithm instance. If this algo want to use
          samplers, it should have a `_sampler` field.
      env (Environment): An environment instance.
docstr_tok: ["Set","up","trainer","for","algorithm","and","environment",".","This","method","saves","algo","and","env","within","trainer","and","creates","a","sampler",".","Note",":","After","setup","(",")","is","called","all","variables","in","session","should","have","been","initialized",".","setup","(",")","respects","existing","values","in","session","so","policy","weights","can","be","loaded","before","setup","(",")",".","Args",":","algo","(","RLAlgorithm",")",":","An","algorithm","instance",".","If","this","algo","want","to","use","samplers",",","it","should","have","a","`","_sampler","`","field",".","env","(","Environment",")",":","An","environment","instance","."]
code: def setup(self, algo, env):
      """Set up trainer for algorithm and environment.
  
      This method saves algo and env within trainer and creates a sampler.
  
      Note:
          After setup() is called all variables in session should have been
          initialized. setup() respects existing values in session so
          policy weights can be loaded before setup().
  
      Args:
          algo (RLAlgorithm): An algorithm instance. If this algo want to use
              samplers, it should have a `_sampler` field.
          env (Environment): An environment instance.
  
      """
      self._algo = algo
      self._env = env
  
      self._seed = get_seed()
  
      if hasattr(self._algo, "_sampler"):
          # pylint: disable=protected-access
          self._sampler = self._algo._sampler
  
      self._has_setup = True
  
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 2 for calling the Trainer obj's underlying member method code with example usage: obj.setup(algo, env) without return types