code: def convert_np_array_to_tuple(
      arr: np.ndarray,
  ) -> Union[Tuple, np.ndarray]:
      """
      Recursive conversion of numpy arrays with an arbitrary number of dimensions to tuples.
      :param arr: numpy array to convert.
      :return: n-dimensional tuple.
      """
  
      try:
          return tuple(convert_np_array_to_tuple(i) for i in arr)
      except TypeError:
          return arr
  
imports: import inspect
  from typing import Tuple, Any, Dict, Type, List, Union
  import numpy
  from torch import nn
  from maze.core.annotations import override
  from maze.core.env.base_env import BaseEnv
  from maze.core.env.maze_env import MazeEnv
  from maze.perception.models.built_in.flatten_concat import FlattenConcatPolicyNet
  from maze.perception.models.custom_model_composer import CustomModelComposer
  from maze.perception.models.policies import ProbabilisticPolicyComposer
  from maze.test.shared_test_utils.dummy_env.dummy_core_env import DummyCoreEnvironment
  from maze.test.shared_test_utils.dummy_env.dummy_maze_env import DummyEnvironment
  from maze.test.shared_test_utils.dummy_env.dummy_struct_env import DummyStructuredEnvironment
  from maze.test.shared_test_utils.dummy_env.dummy_structured_core_env import DummyStructuredCoreEnvironment
  from maze.test.shared_test_utils.dummy_env.space_interfaces.action_conversion.dict import DictActionConversion
  from maze.test.shared_test_utils.dummy_env.space_interfaces.action_conversion.dict_discrete import DictDiscreteActionConversion
  from maze.test.shared_test_utils.dummy_env.space_interfaces.observation_conversion.dict import ObservationConversion
label_desc: Use image node_id 8 for calling a global function with example usage: convert_np_array_to_tuple(arr) and returns: tuple, arr