class_docstr: Worker with a single policy and multiple environments.
  
  Alternates between taking a single step in all environments and asking the
  policy for an action for every environment. This allows computing a batch
  of actions, which is generally much more efficient than computing a single
  action when using neural networks.
  
  Args:
      seed (int): The seed to use to intialize random number generators.
      max_episode_length (int or float): The maximum length of episodes which
          will be sampled. Can be (floating point) infinity.
      worker_number (int): The number of the worker this update is
          occurring in. This argument is used  set a different seed for
          each worker.
      n_envs (int): Number of environment copies to use.
class_docstr_tok: ["Worker","with","a","single","policy","and","multiple","environments",".","Alternates","between","taking","a","single","step","in","all","environments","and","asking","the","policy","for","an","action","for","every","environment",".","This","allows","computing","a","batch","of","actions",",","which","is","generally","much","more","efficient","than","computing","a","single","action","when","using","neural","networks",".","Args",":","seed","(","int",")",":","The","seed","to","use","to","intialize","random","number","generators",".","max_episode_length","(","int","or","float",")",":","The","maximum","length","of","episodes","which","will","be","sampled",".","Can","be","(","floating","point",")","infinity",".","worker_number","(","int",")",":","The","number","of","the","worker","this","update","is","occurring","in",".","This","argument","is","used","set","a","different","seed","for","each","worker",".","n_envs","(","int",")",":","Number","of","environment","copies","to","use","."]
docstr: Update the environments.
  
  If passed a list (*inside* this list passed to the Sampler itself),
  distributes the environments across the "vectorization" dimension.
  
  Args:
      env_update(Environment or EnvUpdate or None): The environment to
          replace the existing env with. Note that other implementations
          of `Worker` may take different types for this parameter.
  
  Raises:
      TypeError: If env_update is not one of the documented types.
      ValueError: If the wrong number of updates is passed.
docstr_tok: ["Update","the","environments",".","If","passed","a","list","(","*","inside","*","this","list","passed","to","the","Sampler","itself",")",",","distributes","the","environments","across","the","``","vectorization","''","dimension",".","Args",":","env_update","(","Environment","or","EnvUpdate","or","None",")",":","The","environment","to","replace","the","existing","env","with",".","Note","that","other","implementations","of","`","Worker","`","may","take","different","types","for","this","parameter",".","Raises",":","TypeError",":","If","env_update","is","not","one","of","the","documented","types",".","ValueError",":","If","the","wrong","number","of","updates","is","passed","."]
code: def update_env(self, env_update):
      """Update the environments.
  
      If passed a list (*inside* this list passed to the Sampler itself),
      distributes the environments across the "vectorization" dimension.
  
      Args:
          env_update(Environment or EnvUpdate or None): The environment to
              replace the existing env with. Note that other implementations
              of `Worker` may take different types for this parameter.
  
      Raises:
          TypeError: If env_update is not one of the documented types.
          ValueError: If the wrong number of updates is passed.
      """
      if isinstance(env_update, list):
          if len(env_update) != self._n_envs:
              raise ValueError(
                  "If separate environments are passed for "
                  "each worker, there must be exactly n_envs "
                  "({}) environments, but received {} "
                  "environments.".format(self._n_envs, len(env_update))
              )
      elif env_update is not None:
          env_update = [
              copy.deepcopy(env_update) for _ in range(self._n_envs)
          ]
      if env_update:
          for env_index, env_up in enumerate(env_update):
              self._envs[env_index], up = _apply_env_update(
                  self._envs[env_index], env_up
              )
              self._needs_env_reset |= up
  
file_path: garage/src/garage/sampler/vec_worker.py
imports: import collections
  import copy
  import numpy
  from garage import EpisodeBatch, StepType
  from garage.sampler import _apply_env_update
  from garage.sampler.default_worker import DefaultWorker
label_desc: Use image node_id 3 for calling the VecWorker obj's underlying member method code with example usage: obj.update_env(env_update) without return types