code: def _device_check_helper(batch_device, module_device):
      assert batch_device.type == module_device.type
      if (
          batch_device.index is not None
          and module_device.index is not None
      ):
          assert batch_device.index == module_device.index
      else:
          # devices with index None are the same as with index 0
          assert batch_device.index in (0, None)
          assert module_device.index in (0, None)
  
imports: import pytest
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 1 for calling a global function with example usage: _device_check_helper(batch_device, module_device) without return types