def override_tensor_totype():
    r"""Override _tensor_totype to avoid triggering fp64 error when printing XPU tensor on ATS-M"""

    def fp64_tensor_totype_wrapper(f):
        @wraps(f)
        def wrapper(*args, **kwargs):
            for arg in args:
                if torch.is_tensor(arg) and arg.is_xpu:
                    return arg.to(torch.float)
            for k, kwarg in kwargs.items():
                if torch.is_tensor(kwarg) and kwarg.is_xpu:
                    return kwarg.to(torch.float)
            return f(*args, **kwargs)

        return wrapper

    torch._tensor_str.tensor_totype = fp64_tensor_totype_wrapper(
        torch._tensor_str.tensor_totype
    )
Override _tensor_totype to avoid triggering fp64 error when printing XPU tensor on ATS-M
intel_extension_for_pytorch/xpu/overrides.py