code: def test_record_video_within_vector():
      step_trigger = modulo_step_trigger(100)
      n_steps = 199
      expected_video = 2
  
      envs = gym.vector.make(
          "CartPole-v1",
          num_envs=2,
          asynchronous=True,
          render_mode="rgb_array_list",
      )
      envs.reset()
      episode_frames = []
      step_starting_index = 0
      episode_index = 0
      for step_index in range(n_steps):
          _, _, terminated, truncated, _ = envs.step(
              envs.action_space.sample()
          )
          episode_frames.extend(envs.call("render")[0])
  
          if np.any(np.logical_or(terminated, truncated)):
              save_video(
                  episode_frames,
                  "videos",
                  fps=envs.metadata["render_fps"],
                  step_trigger=step_trigger,
                  step_starting_index=step_starting_index,
                  episode_index=episode_index,
              )
              episode_frames = []
              step_starting_index = step_index + 1
              episode_index += 1
  
              # TODO: fix this test (see https://github.com/openai/gym/issues/3054)
              if step_trigger(step_index):
                  expected_video -= 1
  
      envs.close()
  
      assert os.path.isdir("videos")
      mp4_files = [
          file for file in os.listdir("videos") if file.endswith(".mp4")
      ]
      shutil.rmtree("videos")
      assert len(mp4_files) == expected_video
  
file_path: gym/tests/utils/test_save_video.py
imports: import os
  import shutil
  import numpy
  import gym
  from gym.utils.save_video import capped_cubic_video_schedule, save_video
label_desc: Use image node_id 4 for calling a global function with example usage: test_record_video_within_vector() without return types