code: def _obj_to_json(o: object):
      """JSON serialization helper."""
      if isinstance(o, np.ndarray):
          return {
              "__class__": "np.ndarray",
              "__value__": o.tolist(),
          }
      elif isinstance(o, (np.number, np.bool_)):
          # Handle numpy scalar types, like np.float32
          # This discards some precision information, but is consistent with using
          # .tolist() on a NumPy array.
          return cast(np.number, o).tolist()  # to regular Python scalar
      elif isinstance(o, types.LitType):
          return (
              o.to_json()
          )  # pytype: disable=attribute-error  # enable-nested-classes
      elif isinstance(o, dtypes.DataTuple):
          return o.to_json()
      elif isinstance(o, tuple):
          return {
              "__class__": "tuple",
              "__value__": list(o),
          }
      elif isinstance(o, MappingProxyType):
          return dict(o)
      else:
          raise TypeError(repr(o) + " is not JSON serializable.")
  
file_path: lit/lit_nlp/lib/serialize.py
imports: import json
  from types import MappingProxyType
  from typing import Any, cast, Optional
  from lit_nlp.api import dtypes
  from lit_nlp.api import types
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _obj_to_json(o) and returns: dict, cast, o, o, dict, dict