Getting torch.cuda.device_count() = 1 but still able to pass 2 as device argument in torch.cuda.device()

Hi,
When I ran torch.cuda.device_count(), I got 1 in output but still able to pass 2(which is greater than device count) as an argument in the torch.cuda.device() method. The documentation here says its a context-manager that changes the selected device but I have just 1 cuda device available, i.e., ‘cuda:0’. Then, how am I not getting any error when I passed 2 as an argument in torch.cuda.device()?

import torch
print(torch.cuda.is_available())
print(torch.cuda.device_count())
x = torch.cuda.device(2)
print(x)
print(x.idx)

output:

True
1
<torch.cuda.device object at 0x000001873064F2B0>
2

And, what does torch.cuda.device(device).idx means? It’s value is same as what I am inputting as an argument in torch.cuda.device().
Please, help me undestand this. Thanks!