code: def test_submodules_device_and_dtype(dst_device_str, dst_type):
      """Test that the device and dtype property updates propagate through mixed nesting of regular nn.Modules and the
      special modules of type DeviceDtypeModuleMixin (e.g. Metric or LightningModule).
      """
      dst_device = torch.device(dst_device_str)
      model = TopModule()
      assert model.device == torch.device("cpu")
      model = model.to(device=dst_device, dtype=dst_type)
      # nn.Module does not have these attributes
      assert not hasattr(model.module, "_device")
      assert not hasattr(model.module, "_dtype")
      # device and dtype change should propagate down into all children
      assert model.device == model.module.module.device == dst_device
      assert model.dtype == model.module.module.dtype == dst_type
  
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 1 for calling a global function with example usage: test_submodules_device_and_dtype(dst_device_str, dst_type) without return types