code: def postprocess_episodes_to_sample_batch(
      episodes: List[SingleAgentEpisode],
  ) -> SampleBatch:
      """Converts the results from sampling with an `EnvRunner` to one `SampleBatch'.
  
      Once the `SampleBatch` will be deprecated this function will be
      deprecated, too.
      """
      batches = []
  
      for episode_or_list in episodes:
          # Without postprocessing (explore=True), we could have
          # a list.
          if isinstance(episode_or_list, list):
              for episode in episode_or_list:
                  batches.append(episode.get_sample_batch())
          # During exploration we have an episode.
          else:
              batches.append(episode_or_list.get_sample_batch())
  
      batch = concat_samples(batches)
      # TODO (sven): During evalaution we do not have infos at all.
      # On the other side, if we leave in infos in training, conversion
      # to tensors throws an exception.
      if SampleBatch.INFOS in batch.keys():
          del batch[SampleBatch.INFOS]
      # Return the SampleBatch.
      return batch
  
file_path: ray/python/ray/rllib/evaluation/postprocessing_v2.py
imports: from typing import List
  import numpy
  import tree
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.core.models.base import STATE_IN
  from ray.rllib.core.rl_module.rl_module import RLModule
  from ray.rllib.env.single_agent_episode import SingleAgentEpisode
  from ray.rllib.evaluation.postprocessing import discount_cumsum
  from ray.rllib.policy.sample_batch import concat_samples, SampleBatch
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.nested_dict import NestedDict
  from ray.rllib.utils.numpy import convert_to_numpy
  from ray.rllib.utils.torch_utils import convert_to_torch_tensor
  from ray.rllib.utils.typing import TensorType
label_desc: Use image node_id 1 for calling a global function with example usage: postprocess_episodes_to_sample_batch(episodes) and returns: batch