(x)
| 55 | """ |
| 56 | |
| 57 | def maybe_to_cpu(x): |
| 58 | try: |
| 59 | like_gpu_tensor = x.device.type == "cuda" and hasattr(x, "to") |
| 60 | except AttributeError: |
| 61 | like_gpu_tensor = False |
| 62 | if like_gpu_tensor: |
| 63 | return x.to(device="cpu") |
| 64 | else: |
| 65 | return x |
| 66 | |
| 67 | @wraps(func) |
| 68 | def wrapped(*args, **kwargs): |