class_docstr: Abstract base class of all samplers.
  
  Implementations of this class should override `construct`,
  `obtain_samples`, and `shutdown_worker`. `construct` takes a
  `WorkerFactory`, which implements most of the RL-specific functionality a
  `Sampler` needs. Specifically, it specifies how to construct `Worker`s,
  which know how to collect episodes and update both agents and environments.
  
  Currently, `__init__` is also part of the interface, but calling it is
  deprecated. `start_worker` is also deprecated, and does not need to be
  implemented.
docstr: Construct this sampler.
  
  Args:
      worker_factory (WorkerFactory): Pickleable factory for creating
          workers. Should be transmitted to other processes / nodes where
          work needs to be done, then workers should be constructed
          there.
      agents (Policy or List[Policy]): Agent(s) to use to collect
          episodes. If a list is passed in, it must have length exactly
          `worker_factory.n_workers`, and will be spread across the
          workers.
      envs (Environment or List[Environment]): Environment from which
          episodes are sampled. If a list is passed in, it must have
          length exactly `worker_factory.n_workers`, and will be spread
          across the workers.
  
  Returns:
      Sampler: An instance of `cls`.
code: def from_worker_factory(cls, worker_factory, agents, envs):
      """Construct this sampler.
  
      Args:
          worker_factory (WorkerFactory): Pickleable factory for creating
              workers. Should be transmitted to other processes / nodes where
              work needs to be done, then workers should be constructed
              there.
          agents (Policy or List[Policy]): Agent(s) to use to collect
              episodes. If a list is passed in, it must have length exactly
              `worker_factory.n_workers`, and will be spread across the
              workers.
          envs (Environment or List[Environment]): Environment from which
              episodes are sampled. If a list is passed in, it must have
              length exactly `worker_factory.n_workers`, and will be spread
              across the workers.
  
      Returns:
          Sampler: An instance of `cls`.
  
      """
      # This implementation works for most current implementations.
      # Relying on this implementation is deprecated, but calling this method
      # is not.
      fake_algo = copy.copy(worker_factory)
      fake_algo.policy = agents
      return cls(fake_algo, envs)
  
file_path: garage/src/garage/sampler/sampler.py
imports: import abc
  import copy
label_desc: Use image node_id 2 for calling the Sampler obj's underlying member method code with example usage: obj.from_worker_factory(cls, worker_factory, agents, envs) and returns: cls