class_docstr: Environment form of a MetaWorld benchmark.
  
  This class is generally less efficient than using a TaskSampler, if that
  can be used instead, since each instance of this class internally caches a
  copy of each environment in the benchmark.
  
  In order to sample tasks from this environment, a benchmark must be passed
  at construction time.
  
  Args:
      benchmark (metaworld.Benchmark or None): The benchmark to wrap.
      kind (str or None): Whether to use test or train tasks.
      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', 'test', or None. Also raisd if
          `add_env_onehot` is used on a metaworld meta learning (not
          multi-task) benchmark.
class_docstr_tok: ["Environment","form","of","a","MetaWorld","benchmark",".","This","class","is","generally","less","efficient","than","using","a","TaskSampler",",","if","that","can","be","used","instead",",","since","each","instance","of","this","class","internally","caches","a","copy","of","each","environment","in","the","benchmark",".","In","order","to","sample","tasks","from","this","environment",",","a","benchmark","must","be","passed","at","construction","time",".","Args",":","benchmark","(","metaworld.Benchmark","or","None",")",":","The","benchmark","to","wrap",".","kind","(","str","or","None",")",":","Whether","to","use","test","or","train","tasks",".","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","'",",","'test","'",",","or","None",".","Also","raisd","if","`","add_env_onehot","`","is","used","on","a","metaworld","meta","learning","(","not","multi-task",")","benchmark","."]
docstr: Samples n_tasks tasks.
  
  Part of the set_task environment protocol. To call this method, a
  benchmark must have been passed in at environment construction.
  
  Args:
      n_tasks (int): Number of tasks to sample.
  
  Returns:
      dict[str,object]: Task object to pass back to `set_task`.
docstr_tok: ["Samples","n_tasks","tasks",".","Part","of","the","set_task","environment","protocol",".","To","call","this","method",",","a","benchmark","must","have","been","passed","in","at","environment","construction",".","Args",":","n_tasks","(","int",")",":","Number","of","tasks","to","sample",".","Returns",":","dict","[","str",",","object","]",":","Task","object","to","pass","back","to","`","set_task","`","."]
code: def sample_tasks(self, n_tasks):
      """Samples n_tasks tasks.
  
      Part of the set_task environment protocol. To call this method, a
      benchmark must have been passed in at environment construction.
  
      Args:
          n_tasks (int): Number of tasks to sample.
  
      Returns:
          dict[str,object]: Task object to pass back to `set_task`.
  
      """
      assert self._constructed_from_benchmark
      tasks = []
      while len(tasks) < n_tasks:
          if self._next_env == len(self._env_list):
              self._next_env = 0
              self._next_task_index += 1
          env_name = self._env_list[self._next_env]
          self._next_env += 1
          env_tasks = self._tasks_by_env[env_name]
          if self._next_task_index >= len(env_tasks):
              random.shuffle(env_tasks)
              self._next_task_index = 0
          tasks.append(env_tasks[self._next_task_index])
      return tasks
  
imports: import random
  from garage import envs
  from garage._environment import Environment
label_desc: Use image node_id 3 for calling the MetaWorldSetTaskEnv obj's underlying member method code with example usage: obj.sample_tasks(n_tasks) and returns: tasks