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: Obtain one batch of samples.
  
  Args:
      itr (int): Index of iteration (epoch).
      batch_size (int): Number of steps in batch.
          This is a hint that the sampler may or may not respect.
      agent_update (object): Value which will be passed into the
          `agent_update_fn` before sampling episodes. If a list is passed
          in, it must have length exactly `factory.n_workers`, and will
          be spread across the workers.
      env_update (object): Value which will be passed into the
          `env_update_fn` before sampling episodes. If a list is passed
          in, it must have length exactly `factory.n_workers`, and will
          be spread across the workers.
  
  Raises:
      ValueError: Raised if the trainer was initialized without a
                  sampler, or batch_size wasn't provided here
                  or to train.
  
  Returns:
      list[dict]: One batch of samples.
docstr_tok: ["Obtain","one","batch","of","samples",".","Args",":","itr","(","int",")",":","Index","of","iteration","(","epoch",")",".","batch_size","(","int",")",":","Number","of","steps","in","batch",".","This","is","a","hint","that","the","sampler","may","or","may","not","respect",".","agent_update","(","object",")",":","Value","which","will","be","passed","into","the","`","agent_update_fn","`","before","sampling","episodes",".","If","a","list","is","passed","in",",","it","must","have","length","exactly","`","factory.n_workers","`",",","and","will","be","spread","across","the","workers",".","env_update","(","object",")",":","Value","which","will","be","passed","into","the","`","env_update_fn","`","before","sampling","episodes",".","If","a","list","is","passed","in",",","it","must","have","length","exactly","`","factory.n_workers","`",",","and","will","be","spread","across","the","workers",".","Raises",":","ValueError",":","Raised","if","the","trainer","was","initialized","without","a","sampler",",","or","batch_size","was","n't","provided","here","or","to","train",".","Returns",":","list","[","dict","]",":","One","batch","of","samples","."]
code: def obtain_samples(
      self, itr, batch_size=None, agent_update=None, env_update=None
  ):
      """Obtain one batch of samples.
  
      Args:
          itr (int): Index of iteration (epoch).
          batch_size (int): Number of steps in batch.
              This is a hint that the sampler may or may not respect.
          agent_update (object): Value which will be passed into the
              `agent_update_fn` before sampling episodes. If a list is passed
              in, it must have length exactly `factory.n_workers`, and will
              be spread across the workers.
          env_update (object): Value which will be passed into the
              `env_update_fn` before sampling episodes. If a list is passed
              in, it must have length exactly `factory.n_workers`, and will
              be spread across the workers.
  
      Raises:
          ValueError: Raised if the trainer was initialized without a
                      sampler, or batch_size wasn't provided here
                      or to train.
  
      Returns:
          list[dict]: One batch of samples.
  
      """
      eps = self.obtain_episodes(
          itr, batch_size, agent_update, env_update
      )
      return eps.to_list()
  
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 6 for calling the Trainer obj's underlying member method code with example usage: obj.obtain_samples(itr, batch_size, agent_update, env_update) and returns: eps