code: def run_mpc_autograd_cnn(
      context_manager=None,
      num_epochs=3,
      learning_rate=0.001,
      batch_size=5,
      print_freq=5,
      num_samples=100,
  ):
      """
      Args:
          context_manager: used for setting proxy settings during download.
      """
      crypten.init()
  
      data_alice, data_bob, train_labels = preprocess_mnist(
          context_manager
      )
      rank = comm.get().get_rank()
  
      # assumes at least two parties exist
      # broadcast dummy data with same shape to remaining parties
      if rank == 0:
          x_alice = data_alice
      else:
          x_alice = torch.empty(data_alice.size())
  
      if rank == 1:
          x_bob = data_bob
      else:
          x_bob = torch.empty(data_bob.size())
  
      # encrypt
      x_alice_enc = crypten.cryptensor(x_alice, src=0)
      x_bob_enc = crypten.cryptensor(x_bob, src=1)
  
      # combine feature sets
      x_combined_enc = crypten.cat([x_alice_enc, x_bob_enc], dim=2)
      x_combined_enc = x_combined_enc.unsqueeze(1)
  
      # reduce training set to num_samples
      x_reduced = x_combined_enc[:num_samples]
      y_reduced = train_labels[:num_samples]
  
      # encrypt plaintext model
      model_plaintext = CNN()
      dummy_input = torch.empty((1, 1, 28, 28))
      model = crypten.nn.from_pytorch(model_plaintext, dummy_input)
      model.train()
      model.encrypt()
  
      # encrypted training
      train_encrypted(
          x_reduced,
          y_reduced,
          model,
          num_epochs,
          learning_rate,
          batch_size,
          print_freq,
      )
  
file_path: CrypTen/examples/mpc_autograd_cnn/mpc_autograd_cnn.py
imports: import tempfile
  import crypten
  import crypten.communicator
  import torch
  import torch.nn
  import torch.nn.functional
  from examples.util import NoopContextManager
  from torchvision import datasets, transforms
label_desc: Use image node_id 1 for calling a global function with example usage: run_mpc_autograd_cnn(context_manager, num_epochs, learning_rate, batch_size, print_freq, num_samples) without return types