code: def _test_device(self, device):
      for p in self.pytorch_network.parameters():
          self.assertEqual(p.device, device)
  
      for p in self.optimizer.state.keys():
          if torch.is_tensor(p):
              self.assertEqual(p.device, device)
  
      for param_group in self.optimizer.param_groups:
          for param in param_group["params"]:
              if torch.is_tensor(param):
                  self.assertEqual(param.device, device)
  
              for n, v in self.optimizer.state[param].items():
                  if (
                      "capturable" not in param_group
                      or param_group["capturable"]
                      or n != "step"
                  ):
                      if torch.is_tensor(v):
                          self.assertEqual(v.device, device, n)
  
imports: import os
  from unittest.mock import ANY, MagicMock, call
  import numpy
  import torch
  import torch.nn
  from poutyne import Callback
  from tests.framework.base import CaptureOutputBase
label_desc: Use image node_id 8 for calling the ModelFittingTestCase obj's underlying member method code with example usage: obj._test_device(device) without return types