def METHOD_NAME(data, dtype=None):
    if is_sparse(data):
        return (
            data.astype(dtype)
            if dtype is not None and dtype != data.dtype
            else data
        )
    elif isinstance(data, np.ndarray):
        return sparse.COO.from_numpy(data.astype(dtype, copy=False))
    else:
        return sparse.COO.from_numpy(np.array(data, dtype=dtype))