class_docstr: Tests PyTorch and Tensorflow model imports
docstr: Tests from_pytorch CrypTen training for classification models
docstr_tok: ["Tests","from_pytorch","CrypTen","training","for","classification","models"]
code: def test_from_pytorch_training_classification(self):
      """Tests from_pytorch CrypTen training for classification models"""
      import torch.nn as nn
      import torch.nn.functional as F
  
      class CNN(nn.Module):
          def __init__(self):
              super(CNN, self).__init__()
              self.conv1 = nn.Conv2d(1, 16, kernel_size=5, padding=1)
              self.fc1 = nn.Linear(16 * 13 * 13, 100)
              self.fc2 = nn.Linear(100, 2)
  
          def forward(self, x):
              out = self.conv1(x)
              out = F.relu(out)
              out = F.max_pool2d(out, 2)
              out = out.view(-1, 16 * 13 * 13)
              out = self.fc1(out)
              out = F.relu(out)
              out = self.fc2(out)
              out = F.softmax(out, dim=1)
              return out
  
      model_plaintext = CNN()
      batch_size = 5
      x_orig = get_random_test_tensor(
          size=(batch_size, 1, 28, 28), is_float=True
      )
      y_orig = (
          get_random_test_tensor(size=(batch_size, 1), is_float=True)
          .gt(0)
          .long()
      )
      y_one_hot = onehot(y_orig, num_targets=2)
  
      # encrypt training sample:
      x_train = crypten.cryptensor(x_orig, requires_grad=True)
      y_train = crypten.cryptensor(y_one_hot)
      dummy_input = torch.empty((1, 1, 28, 28))
  
      for loss_name in ["BCELoss", "CrossEntropyLoss"]:
          # create encrypted model
          model = crypten.nn.from_pytorch(model_plaintext, dummy_input)
          model.train()
          model.encrypt()
  
          self._check_training(model, x_train, y_train, loss_name)
  
      self._check_model_export(model, x_train)
  
imports: import collections
  import io
  import logging
  import os
  import unittest
  import crypten
  import torch
  from crypten.common.tensor_types import is_float_tensor
  from crypten.config import cfg
  from crypten.nn import onnx_converter
  from test.multiprocess_test_case import get_random_test_tensor, MultiProcessTestCase, onehot
label_desc: Use image node_id 5 for calling the TestOnnxConverter obj's underlying member method code with example usage: obj.test_from_pytorch_training_classification() and returns: out