class_docstr: Constructs a single sampler worker.
  
  Args:
      worker_id (int): The ID of this worker.
      env (Environment): Environment to sample form.
      agent_pkl (bytes): Pickled :class:`Policy` to sample with.
      worker_factory (WorkerFactory): Factory to construct this worker's
          behavior.
class_docstr_tok: ["Constructs","a","single","sampler","worker",".","Args",":","worker_id","(","int",")",":","The","ID","of","this","worker",".","env","(","Environment",")",":","Environment","to","sample","form",".","agent_pkl","(","bytes",")",":","Pickled",":","class",":","`","Policy","`","to","sample","with",".","worker_factory","(","WorkerFactory",")",":","Factory","to","construct","this","worker's","behavior","."]
code: def __init__(self, worker_id, env, agent_pkl, worker_factory):
      # Must be called before pickle.loads below.
      self.inner_worker = worker_factory(worker_id)
      self.worker_id = worker_id
      self.inner_worker.update_env(env)
      self.inner_worker.update_agent(cloudpickle.loads(agent_pkl))
  
imports: from collections import defaultdict
  import itertools
  import click
  import cloudpickle
  import psutil
  import ray
  from garage import EpisodeBatch
  from garage.experiment.deterministic import get_seed
  from garage.sampler.default_worker import DefaultWorker
  from garage.sampler.sampler import Sampler
  from garage.sampler.worker_factory import WorkerFactory
label_desc: Use image node_id 1 to create a new SamplerWorker object  with example: obj = SamplerWorker(worker_id, env, agent_pkl, worker_factory)