code: def np_val_to_py_type(val):
      """Convert numpy val to python primitive equivalent. Ex:
  
      Given: val = np.array([True, False])
      Returns: [True, False]
  
      Given: val = np.array(32, dtype=np.int32)
      Returns 32
      """
      if not isinstance(val, (_np.ndarray, _np.generic)):
          return val
  
      if val.dtype in (_np.float16, _np.uint8, _np.int8, _np.uint32):
          # Serialize to bytes because MIL read them from bytes field (see TensorValue in MIL.proto).
          return val.tobytes()
      else:
          if val.dtype in (_np.uint16, _np.int16):
              # TODO (rdar://111797203): Serialize to byte after MIL changes to read from byte field.
              val = val.astype(np.int32)
          is_np_scalar = isinstance(val, _np.generic) or val.shape == ()
          py_type = np_dtype_to_py_type(val.dtype)
          return (
              py_type(val)
              if is_np_scalar
              else tuple(py_type(v) for v in val.flatten())
          )
  
imports: from collections import namedtuple
  import numpy
  import numpy
  import sympy
  import coremltools.proto.MIL_pb2
  from .get_type_info import get_type_info
  from .type_bool import bool
  from .type_bool import is_bool
  from .type_complex import complex64
  from .type_complex import complex128
  from .type_complex import is_complex
  from .type_dict import is_dict
  from .type_double import fp16
  from .type_double import fp32
  from .type_double import fp64
  from .type_double import is_float
  from .type_int import int8
  from .type_int import int16
  from .type_int import int32
  from .type_int import int64
  from .type_int import is_int
  from .type_int import uint8
  from .type_int import uint16
  from .type_int import uint32
  from .type_int import uint64
  from .type_list import is_list
  from .type_str import str
  from .type_unknown import unknown
label_desc: Use image node_id 22 for calling a global function with example usage: np_val_to_py_type(val) and returns: val, val, unknown