code: def unbatch(batches_struct):
      """Converts input from (nested) struct of batches to batch of structs.
  
      Input: Struct of different batches (each batch has size=3):
          {
              "a": np.array([1, 2, 3]),
              "b": (np.array([4, 5, 6]), np.array([7.0, 8.0, 9.0]))
          }
      Output: Batch (list) of structs (each of these structs representing a
          single action):
          [
              {"a": 1, "b": (4, 7.0)},  <- action 1
              {"a": 2, "b": (5, 8.0)},  <- action 2
              {"a": 3, "b": (6, 9.0)},  <- action 3
          ]
  
      Args:
          batches_struct: The struct of component batches. Each leaf item
              in this struct represents the batch for a single component
              (in case struct is tuple/dict).
              Alternatively, `batches_struct` may also simply be a batch of
              primitives (non tuple/dict).
  
      Returns:
          The list of individual structs. Each item in the returned list represents a
          single (maybe complex) batch item.
      """
      flat_batches = tree.flatten(batches_struct)
  
      out = []
      for batch_pos in range(len(flat_batches[0])):
          out.append(
              tree.unflatten_as(
                  batches_struct,
                  [
                      flat_batches[i][batch_pos]
                      for i in range(len(flat_batches))
                  ],
              )
          )
      return out
  
file_path: ray/python/ray/rllib/utils/spaces/space_utils.py
imports: import gymnasium
  from gymnasium.spaces import Tuple, Dict
  import numpy
  from ray.rllib.utils.annotations import DeveloperAPI
  import tree
  from typing import Any, List, Optional, Union
label_desc: Use image node_id 7 for calling a global function with example usage: unbatch(batches_struct) and returns: out