class_docstr: This class tests the crypten.nn package.
class_docstr_tok: ["This","class","tests","the","crypten.nn","package","."]
docstr: Tests that all modules from tutorial 5 properly convert to crypten modules using from_pytorch
code: def test_tutorial_modules(self) -> None:
      """Tests that all modules from tutorial 5 properly convert to crypten modules using from_pytorch"""
      input_sizes = {
          AliceNet: (1, 50),
          AliceNet2: (1, 1, 28, 28),
      }
      for torch_class, input_size in input_sizes.items():
          # Create torch model
          torch_model = torch_class()
          torch_model.eval()
  
          # Coordinate model weights across parties
          with torch.no_grad():
              for p in torch_model.parameters():
                  p.set_(
                      get_random_test_tensor(
                          max_value=1.0, size=p.size(), is_float=True
                      )
                  )
  
          # Create CrypTen model
          dummy_input = torch.empty(input_size)
          crypten_model = crypten.nn.from_pytorch(
              torch_model, dummy_input
          )
          crypten_model.encrypt()
  
          # Create test inputs
          test_input = get_random_test_tensor(
              max_value=2.0, size=input_size, is_float=True
          )
          test_input_encr = crypten.cryptensor(test_input)
  
          # Test model forward function
          torch_output = torch_model(test_input)
          crypten_output = crypten_model(test_input_encr)
  
          self._check(
              crypten_output,
              torch_output,
              f"from_pytorch failed for {torch_class}",
          )
  
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 28 for calling the TestNN obj's underlying member method code with example usage: obj.test_tutorial_modules() without return types