Use GPU Acceleration for M1 Macbook.
PyTorch >= 1.12.0
ipykernel (Required)
# Judge whether GPU is avaiable
if torch.backends.mps.is_available()
device = torch.device("mps")
else
device = torch.device("cpu")
# Push model into GPU
model.to(device)