code: def pytorch_cnn(params):
      linear0 = params["linear.0"]
      linear1 = params["linear.1"]
  
      layers = []
  
      in_features = 28 * 28
  
      layers.append(nn.Linear(in_features, linear0))
      layers.append(nn.ReLU())
      layers.append(nn.Dropout(0.2))
  
      layers.append(nn.Linear(linear0, linear1))
      layers.append(nn.ReLU())
      layers.append(nn.Dropout(0.2))
  
      layers.append(nn.Linear(linear1, CLASSES))
      layers.append(nn.LogSoftmax(dim=1))
  
      model = nn.Sequential(*layers)
  
      # model = create_model(params).to(DEVICE)
      optimizer = getattr(optim, "Adam")(model.parameters(), lr=0.01)
  
      # Training of the model.
      for epoch in range(EPOCHS):
          model.train()
          for batch_idx, (data, target) in enumerate(train_loader):
              # Limiting training data for faster epochs.
              if batch_idx * BATCHSIZE >= N_TRAIN_EXAMPLES:
                  break
  
              data, target = data.view(data.size(0), -1).to(
                  DEVICE
              ), target.to(DEVICE)
  
              optimizer.zero_grad()
              output = model(data)
              loss = F.nll_loss(output, target)
              loss.backward()
              optimizer.step()
  
          # Validation of the model.
          model.eval()
          correct = 0
          with torch.no_grad():
              for batch_idx, (data, target) in enumerate(valid_loader):
                  # Limiting validation data.
                  if batch_idx * BATCHSIZE >= N_VALID_EXAMPLES:
                      break
                  data, target = data.view(data.size(0), -1).to(
                      DEVICE
                  ), target.to(DEVICE)
                  output = model(data)
                  # Get the index of the max log-probability.
                  pred = output.argmax(dim=1, keepdim=True)
                  correct += pred.eq(target.view_as(pred)).sum().item()
  
          accuracy = correct / min(
              len(valid_loader.dataset), N_VALID_EXAMPLES
          )
  
      return accuracy
  
file_path: Hyperactive/examples/tested_and_supported_packages/pytorch_example.py
imports: import os
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import torch.utils.data
  from torchvision import datasets
  from torchvision import transforms
  from hyperactive import Hyperactive
label_desc: Use image node_id 1 for calling a global function with example usage: pytorch_cnn(params) and returns: accuracy