def numpy_type_to_builtin_type(nptype) -> type:
    """
    Converts a numpy type to its builtin `types` equivalent.
    Supports Python native types and numpy types.
    """
    if isinstance(nptype, np.dtype):
        builtin_type = _numpy_dtype_instance_to_builtin_type(nptype)
        if builtin_type is not None:
            return builtin_type

    # If this is a data type object, use the corresponding scalar data type.
    if issubclass(type(nptype), np.dtype):
        nptype = nptype.type

    if issubclass(nptype, (bool, np.bool_)):
        # numpy as 2 bool types it looks like. what is the difference?
        return types_bool
    # Because np.uint is a subclass of int,
    # we need to first check for np.uint before
    # checking for int
    elif issubclass(nptype, np.uint8):
        return types_uint8
    elif issubclass(nptype, np.int8):
        return types_int8
    elif issubclass(nptype, np.uint16):
        return types_uint16
    elif issubclass(nptype, np.int16):
        return types_int16
    elif issubclass(nptype, np.uint32):
        return types_uint32
    elif issubclass(nptype, np.int32):
        return types_int32
    elif issubclass(nptype, np.uint64):
        return types_uint64
    elif issubclass(nptype, np.int64):
        return types_int64
    elif issubclass(nptype, int) or nptype == int:
        # Catch all int
        return types_int32
    elif issubclass(nptype, np.object_):
        # symbolic shape is considered int32
        return types_int32
    elif issubclass(nptype, np.float16):
        return types_fp16
    elif (
        issubclass(nptype, (np.float32, np.single)) or nptype == float
    ):
        return types_fp32
    elif issubclass(nptype, (np.float64, np.double)):
        return types_fp64
    elif issubclass(nptype, np.complex64):
        return types_complex64
    elif issubclass(nptype, (np.complex128, complex)):
        return types_complex128
    elif issubclass(nptype, (str, np.bytes_, np.str_)):
        return types_str
    else:
        raise TypeError(f"Unsupported numpy type: {nptype}.")

    Converts a numpy type to its builtin `types` equivalent.
    Supports Python native types and numpy types.
    
coremltools/converters/mil/mil/types/type_mapping.py