importtorchdtypes=[torch.float,torch.double]devices=[torch.device('cpu')]iftorch.cuda.is_available():# pragma: no coverdevices+=[torch.device('cuda:{}'.format(torch.cuda.current_device()))]deftensor(x,dtype,device):returnNoneifxisNoneelsetorch.tensor(x,dtype=dtype,device=device)