import torch def get_device(): """Auto-detect best available device: CUDA → MPS → CPU.""" if torch.cuda.is_available(): return torch.device("cuda") elif torch.backends.mps.is_available(): return torch.device("mps") else: return torch.device("cpu")