code: def test_in_local_sampler(
      policy, envs, other_envs, timesteps_per_call
  ):
      true_workers = WorkerFactory(
          seed=100,
          n_workers=N_EPS,
          max_episode_length=MAX_EPISODE_LENGTH,
      )
      true_sampler = LocalSampler.from_worker_factory(
          true_workers, policy, envs
      )
      worker_args = dict(
          n_envs=N_EPS, timesteps_per_call=timesteps_per_call
      )
      vec_workers = WorkerFactory(
          seed=100,
          n_workers=1,
          worker_class=FragmentWorker,
          worker_args=worker_args,
          max_episode_length=MAX_EPISODE_LENGTH,
      )
      vec_sampler = LocalSampler.from_worker_factory(
          vec_workers, policy, [envs]
      )
      n_samples = 400
  
      true_eps = true_sampler.obtain_samples(0, n_samples, None)
      sliced_true_eps = slice_episodes(true_eps, timesteps_per_call)
  
      vec_eps = vec_sampler.obtain_samples(0, 50, None)
      for test_eps in vec_eps.split():
          assert any(
              eps_eq(true_eps, test_eps) for true_eps in sliced_true_eps
          )
  
      true_eps = true_sampler.obtain_samples(
          0, n_samples, None, env_update=other_envs
      )
      sliced_true_eps = slice_episodes(true_eps, timesteps_per_call)
  
      vec_eps = vec_sampler.obtain_samples(
          0, 50, None, env_update=[other_envs]
      )
      for test_eps in vec_eps.split():
          assert any(
              eps_eq(true_eps, test_eps) for true_eps in sliced_true_eps
          )
  
      true_sampler.shutdown_worker()
      vec_sampler.shutdown_worker()
  
file_path: garage/tests/garage/sampler/test_fragment_worker.py
imports: import math
  import pprint
  import numpy
  import pytest
  from garage import EpisodeBatch, StepType
  from garage.envs import GridWorldEnv, PointEnv
  from garage.experiment.task_sampler import SetTaskSampler
  from garage.np.policies import FixedPolicy, ScriptedPolicy
  from garage.sampler import FragmentWorker, LocalSampler, WorkerFactory
label_desc: Use image node_id 8 for calling a global function with example usage: test_in_local_sampler(policy, envs, other_envs, timesteps_per_call) without return types