code: def _apply_recursive(
      data: Union[
          np.ndarray, List[Any], Tuple[Any, ...], Dict[str, Any]
      ],
      fn: Callable[[Any], Any],
  ) -> Union[List[Any], Tuple[Any, ...], Dict[str, Any]]:
      """Applies a function recursively to the nested dimensions of the input.
  
      Args:
        data: scalar, array, list, tuple or dictionary.
        fn: function to apply to the most nested dimension.
  
      Returns:
        item with the same shape of data but with fn applied to the most nested
        dimension
      """
      if isinstance(data, dict):
          return {k: _apply_recursive(data[k], fn) for k in data}
      elif isinstance(data, tuple):
          return tuple(_apply_recursive(x, fn) for x in data)
      else:
          return fn(data)
  
file_path: datasets/tensorflow_datasets/rlds/envlogger_reader.py
imports: from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Tuple, Union
  import numpy
  from tensorflow_datasets.core.utils import tree_utils
label_desc: Use image node_id 10 for calling a global function with example usage: _apply_recursive(data, fn) and returns: unknown, tuple, fn