code: def make_env(
      env_id: str,
      seed: int,
      idx: int,
      capture_video: bool,
      run_name: Optional[str] = None,
      prefix: str = "",
  ):
      def thunk():
          env = gym.make(env_id, render_mode="rgb_array")
          env = gym.wrappers.RecordEpisodeStatistics(env)
          if capture_video and idx == 0 and run_name is not None:
              env = gym.wrappers.RecordVideo(
                  env,
                  os.path.join(
                      run_name,
                      prefix + "_videos" if prefix else "videos",
                  ),
                  disable_logger=True,
              )
          env.action_space.seed(seed)
          env.observation_space.seed(seed)
          return env
  
      return thunk
  
file_path: pytorch-lightning/examples/fabric/reinforcement_learning/rl/utils.py
imports: import argparse
  import math
  import os
  from distutils.util import strtobool
  from typing import TYPE_CHECKING, Optional, Union
  import gymnasium
  import torch
  from torch.utils.tensorboard import SummaryWriter
label_desc: Use image node_id 4 for calling a global function with example usage: make_env(env_id, seed, idx, capture_video, run_name, prefix) and returns: thunk, env