code: def test_device_if_child_module(metric_class):
      """Test that if a metric is a child module all values gets moved to the correct device."""
  
      class TestModule(Module):
          def __init__(self) -> None:
              super().__init__()
              self.metric = metric_class()
              self.register_buffer("dummy", torch.zeros(1))
  
          @property
          def device(self):
              return self.dummy.device
  
      module = TestModule()
  
      assert module.device == module.metric.device
      if isinstance(module.metric.x, Tensor):
          assert module.device == module.metric.x.device
  
      module.to(device="cuda")
  
      assert module.device == module.metric.device
      if isinstance(module.metric.x, Tensor):
          assert module.device == module.metric.x.device
  
imports: import os
  import pickle
  from collections import OrderedDict
  from typing import Any
  from unittest.mock import Mock
  import cloudpickle
  import numpy
  import psutil
  import pytest
  import torch
  from torch import Tensor, tensor
  from torch.nn import Module, Parameter
  from torchmetrics.classification import BinaryAccuracy
  from torchmetrics.regression import PearsonCorrCoef
  from unittests.helpers import seed_all
  from unittests.helpers.testers import DummyListMetric, DummyMetric, DummyMetricMultiOutput, DummyMetricSum
  from unittests.helpers.utilities import no_warning_call
label_desc: Use image node_id 22 for calling a global function with example usage: test_device_if_child_module(metric_class) and returns: self