code: def test_set_task_task_sampler_ml10():
      # Import, construct environments here to avoid using up too much
      # resources if this test isn't run.
      # pylint: disable=import-outside-toplevel
      import metaworld
  
      ml10 = metaworld.ML10()
      tasks = task_sampler.MetaWorldTaskSampler(ml10, "test")
      assert tasks.n_tasks == 5 * 50
      with pytest.raises(ValueError):
          tasks.sample(1)
      updates = tasks.sample(10)
      envs = [update() for update in updates]
      for env in envs:
          env.reset()
      action = envs[0].action_space.sample()
      rewards = [env.step(action).reward for env in envs]
      assert np.var(rewards) > 0
      env = envs[0]
      env.close = unittest.mock.MagicMock(name="env.close")
      updates[1](env)
      env.close.assert_not_called()
      updates[2](env)
      env.close.assert_called()
  
file_path: garage/tests/garage/experiment/test_task_sampler.py
imports: import functools
  import unittest.mock
  import numpy
  import pytest
  from garage.experiment import task_sampler
  from garage.envs.mujoco.half_cheetah_vel_env import HalfCheetahVelEnv
label_desc: Use image node_id 3 for calling a global function with example usage: test_set_task_task_sampler_ml10() without return types