class_docstr: TaskSampler that distributes a Meta-World benchmark across workers.
  
  Args:
      benchmark (metaworld.Benchmark): Benchmark to sample tasks from.
      kind (str): Must be either 'test' or 'train'. Determines whether to
          sample training or test tasks from the Benchmark.
      wrapper (Callable[garage.Env, garage.Env] or None): Wrapper to apply to
          env instances.
      add_env_onehot (bool): If true, a one-hot representing the current
          environment name will be added to the environments. Should only be
          used with multi-task benchmarks.
  
  Raises:
      ValueError: If kind is not 'train' or 'test'. Also raisd if
          `add_env_onehot` is used on a metaworld meta learning (not
          multi-task) benchmark.
class_docstr_tok: ["TaskSampler","that","distributes","a","Meta-World","benchmark","across","workers",".","Args",":","benchmark","(","metaworld.Benchmark",")",":","Benchmark","to","sample","tasks","from",".","kind","(","str",")",":","Must","be","either","'test","'","or","'train","'",".","Determines","whether","to","sample","training","or","test","tasks","from","the","Benchmark",".","wrapper","(","Callable","[","garage.Env",",","garage.Env","]","or","None",")",":","Wrapper","to","apply","to","env","instances",".","add_env_onehot","(","bool",")",":","If","true",",","a","one-hot","representing","the","current","environment","name","will","be","added","to","the","environments",".","Should","only","be","used","with","multi-task","benchmarks",".","Raises",":","ValueError",":","If","kind","is","not","'train","'","or","'test","'",".","Also","raisd","if","`","add_env_onehot","`","is","used","on","a","metaworld","meta","learning","(","not","multi-task",")","benchmark","."]
code: def __init__(
      self, benchmark, kind, wrapper=None, add_env_onehot=False
  ):
      self._benchmark = benchmark
      self._kind = kind
      self._inner_wrapper = wrapper
      self._add_env_onehot = add_env_onehot
      if kind == "train":
          self._classes = benchmark.train_classes
          self._tasks = benchmark.train_tasks
      elif kind == "test":
          self._classes = benchmark.test_classes
          self._tasks = benchmark.test_tasks
      else:
          raise ValueError(
              'kind must be either "train" or "test", ' f"not {kind!r}"
          )
      self._task_indices = {}
      if add_env_onehot:
          if kind == "test" or "metaworld.ML" in repr(type(benchmark)):
              raise ValueError(
                  "add_env_onehot should only be used with "
                  f"multi-task benchmarks, not {benchmark!r}"
              )
          self._task_indices = {
              env_name: index
              for (index, env_name) in enumerate(self._classes.keys())
          }
      self._task_map = {
          env_name: [
              task for task in self._tasks if task.env_name == env_name
          ]
          for env_name in self._classes.keys()
      }
      for tasks in self._task_map.values():
          assert len(tasks) == MW_TASKS_PER_ENV
      self._task_orders = {
          env_name: np.arange(50) for env_name in self._task_map.keys()
      }
      self._next_order_index = 0
      self._shuffle_tasks()
  
imports: import abc
  import copy
  import math
  import numpy
  from garage.envs import GymEnv, TaskNameWrapper, TaskOnehotWrapper
  from garage.sampler.env_update import ExistingEnvUpdate, NewEnvUpdate, SetTaskUpdate
label_desc: Use image node_id 1 to create a new MetaWorldTaskSampler object from inherited base classes: TaskSampler with example: obj = MetaWorldTaskSampler(benchmark, kind, wrapper, add_env_onehot)