code: def _encode_object(obj):
      """Try to encode `obj` as a netCDF/Zarr compatible datatype which most closely resembles the object's nature.
  
      Raises:
          ValueError if no such datatype could be found
      """
      is_nonbool_int = isinstance(obj, int) and not isinstance(
          obj, (bool, np.bool_)
      )
      is_encode_type = isinstance(
          obj, (float, str, np.integer, np.floating)
      )
      if is_nonbool_int or is_encode_type:
          return obj
      elif isinstance(obj, np.ndarray):
          return _encode_numpy_array(obj)
      raise ValueError("Unable to encode")
  
imports: from __future__ import annotations
  import datetime
  import json
  import logging
  from collections import OrderedDict
  import numpy
  import xarray
  from satpy.writers.utils import flatten_dict
label_desc: Use image node_id 2 for calling a global function with example usage: _encode_object(obj) and returns: obj, _encode_numpy_array