class_docstr: Benchmarks runtime and accuracy of crypten models
  
  Models are benchmarked on synthetically generated
  Gaussian clusters for binary classification. Resnet18 is
  benchmarks use image data.
  
  Args:
      n_samples (int): number of samples for Gaussian cluster model training
      n_features (int): number of features for the Gaussian clusters.
      epochs (int): number of training epochs
      lr_rate (float): learning rate.
class_docstr_tok: ["Benchmarks","runtime","and","accuracy","of","crypten","models","Models","are","benchmarked","on","synthetically","generated","Gaussian","clusters","for","binary","classification",".","Resnet18","is","benchmarks","use","image","data",".","Args",":","n_samples","(","int",")",":","number","of","samples","for","Gaussian","cluster","model","training","n_features","(","int",")",":","number","of","features","for","the","Gaussian","clusters",".","epochs","(","int",")",":","number","of","training","epochs","lr_rate","(","float",")",":","learning","rate","."]
docstr: Trains PyTorch model
  
  Args:
      model (PyTorch model): model to be trained
      x (torch.tensor): inputs
      y (torch.tensor): targets
      epochs (int): number of training epochs
      lr (float): learning rate
      loss (str): type of loss to use for training
  
  Returns:
      model with update weights
docstr_tok: ["Trains","PyTorch","model","Args",":","model","(","PyTorch","model",")",":","model","to","be","trained","x","(","torch.tensor",")",":","inputs","y","(","torch.tensor",")",":","targets","epochs","(","int",")",":","number","of","training","epochs","lr","(","float",")",":","learning","rate","loss","(","str",")",":","type","of","loss","to","use","for","training","Returns",":","model","with","update","weights"]
code: def train(self, model, x, y, epochs, lr, loss):
      """Trains PyTorch model
  
      Args:
          model (PyTorch model): model to be trained
          x (torch.tensor): inputs
          y (torch.tensor): targets
          epochs (int): number of training epochs
          lr (float): learning rate
          loss (str): type of loss to use for training
  
      Returns:
          model with update weights
      """
      assert isinstance(
          model, torch.nn.Module
      ), "must be a PyTorch model"
      criterion = getattr(torch.nn, loss)()
      optimizer = torch.optim.SGD(model.parameters(), lr=lr)
  
      for _ in range(epochs):
          model.zero_grad()
          output = model(x)
          loss = criterion(output, y)
          loss.backward()
          optimizer.step()
  
      return model
  
imports: import argparse
  import functools
  import os
  import timeit
  from collections import namedtuple
  import crypten
  import crypten.communicator
  import numpy
  import pandas
  import torch
  from examples import multiprocess_launcher
label_desc: Use image node_id 4 for calling the ModelBenchmarks obj's underlying member method code with example usage: obj.train(model, x, y, epochs, lr, loss) and returns: model