code: def _mock_multi_agent_records_from_env(
      self,
      size: int = 100,
      episode: MultiAgentEpisode = None,
      env: gym.Env = None,
      init: bool = True,
      truncate: bool = True,
      seed: Optional[int] = 42,
  ) -> Tuple[MultiAgentEpisode, gym.Env]:
      # If the environment does not yet exist, create one.
      if not env:
          env = MultiAgentTestEnv(truncate=truncate)
  
      # If no episode is given, construct one.
      if episode is None:
          # We give it the `agent_ids` to make it create all objects.
          episode = MultiAgentEpisode(agent_ids=env._agent_ids)
  
      # We initialize the episode, if requested.
      if init:
          obs, info = env.reset(seed=seed)
          episode.add_env_reset(observations=obs, infos=info)
      # In the other case wer need at least the last observations for the next
      # actions.
      else:
          obs = {
              agent_id: agent_obs
              for agent_id, agent_obs in episode.get_observations().items()
              if episode.agent_buffers[agent_id]["actions"].empty()
          }
  
      # Sample `size` many records.
      for i in range(env.t, env.t + size):
          action = {agent_id: i + 1 for agent_id in obs}
          obs, reward, terminated, truncated, info = env.step(action)
          episode.add_env_step(
              observations=obs,
              actions=action,
              rewards=reward,
              infos=info,
              terminateds=terminated,
              truncateds=truncated,
              extra_model_outputs={
                  agent_id: {"extra": 10} for agent_id in action
              },
          )
  
      # Return both, epsiode and environment.
      return episode, env
  
imports: import gymnasium
  import numpy
  import unittest
  from typing import List, Optional, Tuple
  import ray
  from ray.rllib.env.multi_agent_env import MultiAgentEnv
  from ray.rllib.env.multi_agent_episode import MultiAgentEpisode
  from ray.rllib.utils.typing import MultiAgentDict
label_desc: Use image node_id 12 for calling the TestMultiAgentEpisode obj's underlying member method code with example usage: obj._mock_multi_agent_records_from_env(size, episode, env, init, truncate, seed) and returns: episode,  env