code: def flatten_to_single_ndarray(input_):
      """Returns a single np.ndarray given a list/tuple of np.ndarrays.
  
      Args:
          input_ (Union[List[np.ndarray], np.ndarray]): The list of ndarrays or
              a single ndarray.
  
      Returns:
          np.ndarray: The result after concatenating all single arrays in input_.
  
      .. testcode::
          :skipif: True
  
          flatten_to_single_ndarray([
              np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]),
              np.array([7, 8, 9]),
          ])
  
      .. testoutput::
  
          np.array([
              1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0
          ])
      """
      # Concatenate complex inputs.
      if isinstance(input_, (list, tuple, dict)):
          expanded = []
          for in_ in tree.flatten(input_):
              expanded.append(np.reshape(in_, [-1]))
          input_ = np.concatenate(expanded, axis=0).flatten()
      return input_
  
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 5 for calling a global function with example usage: flatten_to_single_ndarray(input_) and returns: input_