src/transformers/utils/import_utils.py/is_torch_bf16_cpu_available
def is_torch_bf16_cpu_available():
    if not is_torch_available():
        return False

    import torch

    if version.parse(version.parse(torch.__version__).base_version) < version.parse("1.10"):
        return False

    try:
        # multiple levels of AttributeError depending on the pytorch version so do them all in one check
        _ = torch.cpu.amp.autocast
    except AttributeError:
        return False

    return True