import torch
from typing import Tuple
from typing import Union


def _dtype_min_max(dtype: torch.dtype) -> Tuple[Union[float, int], Union[float, int]]:
    """Get the min and max values for a dtype"""
    dinfo = torch.finfo(dtype) if dtype.is_floating_point else torch.iinfo(dtype)
    return dinfo.min, dinfo.max