from typing import Any
import torch


def infer_device(x: Any):
    """Infer the device of any object (CPU for any non-torch object)"""
    if isinstance(x, torch.Tensor):
        return x.device
    return torch.device("cpu")