class_docstr: This class tests the crypten.nn package.
class_docstr_tok: ["This","class","tests","the","crypten.nn","package","."]
docstr: Test Module.to, Module.cpu, and Module.cuda
code: def test_to(self) -> None:
      """Test Module.to, Module.cpu, and Module.cuda"""
      module_list = [crypten.nn.Linear(10, 10) for _ in range(3)]
      model = crypten.nn.Sequential(*module_list)
  
      model_cpu = model.to("cpu")
      cpu = torch.device("cpu")
      for param in model_cpu.parameters():
          self.assertEqual(param.device, cpu)
      for buffer in model_cpu.buffers():
          self.assertEqual(buffer.device, cpu)
  
      model_cpu = model.cpu()
      for param in model_cpu.parameters():
          self.assertEqual(param.device, cpu)
      for buffer in model_cpu.buffers():
          self.assertEqual(buffer.device, cpu)
  
      if torch.cuda.is_available():
          cuda = torch.device("cuda:0")
          model_cuda = model.cuda()
          for param in model_cuda.parameters():
              self.assertEqual(param.device, cuda)
          for buffer in model_cuda.buffers():
              self.assertEqual(buffer.device, cuda)
  
          model_cuda = model.to("cuda:0")
          for param in model_cuda.parameters():
              self.assertEqual(param.device, cuda)
          for buffer in model_cuda.buffers():
              self.assertEqual(buffer.device, cuda)
  
imports: import copy
  import itertools
  import logging
  import unittest
  import crypten
  import crypten.communicator
  import torch
  import torch.nn.functional
  from crypten.common.rng import generate_random_ring_element
  from crypten.common.tensor_types import is_float_tensor
  from crypten.config import cfg
  from crypten.encoder import FixedPointEncoder
  from test.multiprocess_test_case import get_random_linear, get_random_test_tensor, MultiProcessTestCase, onehot
label_desc: Use image node_id 24 for calling the TestNN obj's underlying member method code with example usage: obj.test_to() without return types