code: def _offline_gym(
      env: Gym,
      agent: Agent,
      pkl_path: str,
      num_train_transitions: int,
      max_steps: Optional[int],
      seed: int = 1,
  ):
      initialize_seed(seed, env)
  
      replay_buffer = ReplayBuffer(
          replay_capacity=num_train_transitions, batch_size=1
      )
      fill_replay_buffer(
          env, replay_buffer, num_train_transitions, agent
      )
      if isinstance(env.action_space, gym.spaces.Discrete):
          is_discrete_action = True
      else:
          assert isinstance(env.action_space, gym.spaces.Box)
          is_discrete_action = False
      df = replay_buffer_to_pre_timeline_df(
          is_discrete_action, replay_buffer
      )
      logger.info(
          f"Saving dataset with {len(df)} samples to {pkl_path}"
      )
      df.to_pickle(pkl_path)
  
imports: import json
  import logging
  from typing import Optional
  import gym
  import numpy
  import pandas
  import pytorch_lightning
  import torch
  from reagent.data.spark_utils import call_spark_class, get_spark_session
  from reagent.gym.agents.agent import Agent
  from reagent.gym.envs import Gym
  from reagent.gym.policies.predictor_policies import create_predictor_policy_from_model
  from reagent.gym.policies.random_policies import make_random_policy_for_env
  from reagent.gym.runners.gymrunner import evaluate_for_n_episodes
  from reagent.gym.utils import fill_replay_buffer
  from reagent.model_managers.union import ModelManager__Union
  from reagent.publishers.union import FileSystemPublisher, ModelPublisher__Union
  from reagent.replay_memory.circular_replay_buffer import ReplayBuffer
  from reagent.replay_memory.utils import replay_buffer_to_pre_timeline_df
  from .types import TableSpec
label_desc: Use image node_id 4 for calling a global function with example usage: _offline_gym(env, agent, pkl_path, num_train_transitions, max_steps, seed) without return types