def num_bytes(dtype: _torch.dtype) -> int:
    """
    Computes the number of bytes required to represent the input datatype.
    """

    num_bits_in_byte = 8
    if dtype.is_floating_point:
        return _torch.finfo(dtype).bits / num_bits_in_byte
    else:
        return _torch.iinfo(dtype).bits / num_bits_in_byte

    Computes the number of bytes required to represent the input datatype.
    
coremltools/optimize/torch/_utils/graph_utils.py