code: def test_rollout(env, policy, timesteps_per_call):
      worker = FragmentWorker(
          seed=SEED,
          max_episode_length=MAX_EPISODE_LENGTH,
          worker_number=0,
          n_envs=N_EPS,
          timesteps_per_call=timesteps_per_call,
      )
      worker.update_agent(policy)
      worker.update_env(env)
      n_calls = math.ceil(MAX_EPISODE_LENGTH / timesteps_per_call)
      for i in range(n_calls):
          eps = worker.rollout()
          assert sum(eps.lengths) == timesteps_per_call * N_EPS
          if timesteps_per_call * i < 4:
              assert not any(
                  step_type == StepType.TERMINAL
                  for step_type in eps.step_types
              )
      worker.shutdown()
  
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 7 for calling a global function with example usage: test_rollout(env, policy, timesteps_per_call) without return types