code: def test_onehots_consistent_with_task_sampler():
      # Import, construct environments here to avoid using up too much
      # resources if this test isn't run.
      # pylint: disable=import-outside-toplevel
      import metaworld
  
      mt10 = metaworld.MT10()
      env = MetaWorldSetTaskEnv(mt10, "train", add_env_onehot=True)
      policy = RandomPolicy(env.action_space)
      workers = WorkerFactory(
          seed=100, max_episode_length=1, n_workers=10
      )
      sampler1 = LocalSampler.from_worker_factory(workers, policy, env)
      env_ups = [
          SetTaskUpdate(MetaWorldSetTaskEnv, task, None)
          for task in env.sample_tasks(10)
      ]
      samples1 = sampler1.obtain_exact_episodes(1, policy, env_ups)
      task_sampler = MetaWorldTaskSampler(
          mt10, "train", add_env_onehot=True
      )
      env_ups = task_sampler.sample(10)
      sampler2 = LocalSampler.from_worker_factory(
          workers, policy, env_ups
      )
      samples2 = sampler2.obtain_exact_episodes(1, policy, env_ups)
      name_to_obs1 = {}
      for obs1, name1 in zip(
          samples1.observations, samples1.env_infos["task_name"]
      ):
          name_to_obs1[name1] = obs1
      for obs2, name2 in zip(
          samples2.observations, samples2.env_infos["task_name"]
      ):
          assert (name_to_obs1[name2][-10:] == obs2[-10:]).all()
  
file_path: garage/tests/garage/envs/test_metaworld_set_task_env.py
imports: import pytest
  from garage.envs import MetaWorldSetTaskEnv
  from garage.experiment.task_sampler import MetaWorldTaskSampler
  from garage.sampler import LocalSampler, SetTaskUpdate, WorkerFactory
label_desc: Use image node_id 3 for calling a global function with example usage: test_onehots_consistent_with_task_sampler() without return types