parameters: (obj)
docstring: Serializes any object to a JSON-serializable structure.
  
    Args:
        obj: the object to serialize
  
    Returns:
        JSON-serializable structure representing `obj`.
  
    Raises:
        TypeError: if `obj` cannot be serialized.
docstring_summary: Serializes any object to a JSON-serializable structure.
docstring_tokens: Serializes any object to a JSON - serializable structure .
function: def get_json_type(obj):
    """Serializes any object to a JSON-serializable structure.
  
    Args:
        obj: the object to serialize
  
    Returns:
        JSON-serializable structure representing `obj`.
  
    Raises:
        TypeError: if `obj` cannot be serialized.
    """
    # if obj is a serializable Keras class instance
    # e.g. optimizer, layer
    if hasattr(obj, 'get_config'):
      return {'class_name': obj.__class__.__name__, 'config': obj.get_config()}
  
    # if obj is any numpy type
    if type(obj).__module__ == np.__name__:
      if isinstance(obj, np.ndarray):
        return obj.tolist()
      else:
        return obj.item()
  
    # misc functions (e.g. loss function)
    if callable(obj):
      return obj.__name__
  
    # if obj is a python 'type'
    if type(obj).__name__ == type.__name__:
      return obj.__name__
  
    if isinstance(obj, tensor_shape.Dimension):
      return obj.value
  
    if isinstance(obj, tensor_shape.TensorShape):
      return obj.as_list()
  
    if isinstance(obj, dtypes.DType):
      return obj.name
  
    if isinstance(obj, collections.abc.Mapping):
      return dict(obj)
  
    if obj is Ellipsis:
      return {'class_name': '__ellipsis__'}
  
    if isinstance(obj, wrapt.ObjectProxy):
      return obj.__wrapped__
  
    if isinstance(obj, type_spec.TypeSpec):
      try:
        type_spec_name = type_spec.get_name(type(obj))
        return {'class_name': 'TypeSpec', 'type_spec': type_spec_name,
                'serialized': obj._serialize()}  # pylint: disable=protected-access
      except ValueError:
        raise ValueError('Unable to serialize {} to JSON, because the TypeSpec '
                         'class {} has not been registered.'
                         .format(obj, type(obj)))
  
    if isinstance(obj, enum.Enum):
      return obj.value
  
    raise TypeError('Not JSON Serializable:', obj)
function_tokens: def get_json_type ( obj ) : # if obj is a serializable Keras class instance # e.g. optimizer, layer if hasattr ( obj , 'get_config' ) : return { 'class_name' : obj . __class__ . __name__ , 'config' : obj . get_config ( ) } # if obj is any numpy type if type ( obj ) . __module__ == np . __name__ : if isinstance ( obj , np . ndarray ) : return obj . tolist ( ) else : return obj . item ( ) # misc functions (e.g. loss function) if callable ( obj ) : return obj . __name__ # if obj is a python 'type' if type ( obj ) . __name__ == type . __name__ : return obj . __name__ if isinstance ( obj , tensor_shape . Dimension ) : return obj . value if isinstance ( obj , tensor_shape . TensorShape ) : return obj . as_list ( ) if isinstance ( obj , dtypes . DType ) : return obj . name if isinstance ( obj , collections . abc . Mapping ) : return dict ( obj ) if obj is Ellipsis : return { 'class_name' : '__ellipsis__' } if isinstance ( obj , wrapt . ObjectProxy ) : return obj . __wrapped__ if isinstance ( obj , type_spec . TypeSpec ) : try : type_spec_name = type_spec . get_name ( type ( obj ) ) return { 'class_name' : 'TypeSpec' , 'type_spec' : type_spec_name , 'serialized' : obj . _serialize ( ) } # pylint: disable=protected-access except ValueError : raise ValueError ( 'Unable to serialize {} to JSON, because the TypeSpec ' 'class {} has not been registered.' . format ( obj , type ( obj ) ) ) if isinstance ( obj , enum . Enum ) : return obj . value raise TypeError ( 'Not JSON Serializable:' , obj )