code: def _execute_function_on_array_or_scalar(
      function: InputFunc[T],
      data: type_utils.NpArrayOrScalar,
      *args,
      **kwargs,
  ) -> T:
      """Runs `function` on `data`, or each element of `data` if it's an array."""
      if isinstance(data, bytes):
          return function(data, *args, **kwargs)
      if isinstance(data, np.ndarray):
          partial_function = functools.partial(
              function, *args, **kwargs
          )
          return np.array(list(map(partial_function, data)))
      raise ValueError(
          "example should have type `bytes` or `np.ndarray(dtype=bytes)`, but"
          f" has wrong type {type(data)}"
      )
  
imports: from __future__ import annotations
  import enum
  import functools
  from typing import Optional, Protocol, Tuple, TypeVar, Union
  import zlib
  from etils import enp
  import numpy
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.core.utils import dtype_utils
  from tensorflow_datasets.core.utils import np_utils
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _execute_function_on_array_or_scalar(function, data) and returns: function, np