code: def test_cuda_current_device():
      """Test that calling .cuda() moves the model to the correct device and respects current cuda device setting."""
  
      class CudaModule(_DeviceDtypeModuleMixin):
          def __init__(self):
              super().__init__()
              self.layer = nn.Linear(1, 1)
  
      model = CudaModule()
  
      torch.cuda.set_device(0)
      model.cuda(1)
      assert model.device == torch.device("cuda", 1)
      assert model.layer.weight.device == torch.device("cuda", 1)
  
      torch.cuda.set_device(1)
      model.cuda()  # model is already on device 1, and calling .cuda() without device index should not move model
      assert model.device == torch.device("cuda", 1)
      assert model.layer.weight.device == torch.device("cuda", 1)
  
imports: import pytest
  import torch
  from lightning.fabric.utilities.device_dtype_mixin import _DeviceDtypeModuleMixin
  from torch import nn
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 4 for calling a global function with example usage: test_cuda_current_device() without return types