code: def _maybe_train_or_load_digit_classifier_img(path, epochs):
      options = [
          o
          for o in ["mnist", "svhn"]
          if not os.path.exists(path.format(o))
      ]
  
      for option in options:
          print(
              "Cannot find trained {} digit classifier in {}, training...".format(
                  option, path.format(option)
              )
          )
          classifier = globals()[
              "{}_Classifier".format(option.upper())
          ]().to(device)
          criterion = nn.CrossEntropyLoss()
          optimizer = optim.Adam(classifier.parameters(), lr=0.001)
          for epoch in range(
              epochs
          ):  # loop over the dataset multiple times
              running_loss = 0.0
              total_iters = len(train_loader)
              print("\n====> Epoch: {:03d} ".format(epoch))
              for i, data in enumerate(train_loader):
                  # get the inputs
                  x, targets = unpack_data_mlp(data, option)
                  x, targets = x.to(device), targets.to(device)
  
                  optimizer.zero_grad()
                  outputs = classifier(x)
                  loss = criterion(outputs, targets)
                  loss.backward()
                  optimizer.step()
                  # print statistics
                  running_loss += loss.item()
                  if (i + 1) % 1000 == 0:
                      print(
                          "iteration {:04d}/{:d}: loss: {:6.3f}".format(
                              i + 1, total_iters, running_loss / 1000
                          )
                      )
                      running_loss = 0.0
          print("Finished Training, calculating test loss...")
  
          classifier.eval()
          total = 0
          correct = 0
          with torch.no_grad():
              for i, data in enumerate(test_loader):
                  x, targets = unpack_data_mlp(data, option)
                  x, targets = x.to(device), targets.to(device)
                  outputs = classifier(x)
                  _, predicted = torch.max(outputs.data, 1)
                  total += targets.size(0)
                  correct += (predicted == targets).sum().item()
          print(
              "The classifier correctly classified {} out of {} examples. Accuracy: "
              "{:.2f}%".format(correct, total, correct / total * 100)
          )
  
          torch.save(classifier.state_dict(), path.format(option))
  
      mnist_net, svhn_net = MNIST_Classifier().to(
          device
      ), SVHN_Classifier().to(device)
      mnist_net.load_state_dict(torch.load(path.format("mnist")))
      svhn_net.load_state_dict(torch.load(path.format("svhn")))
      return mnist_net, svhn_net
  
file_path: mmvae/src/report/analyse_ms.py
imports: import argparse
  import os
  import sys
  import torch
  import torch.nn
  import torch.optim
  import inspect
  import models
  from helper import Latent_Classifier, SVHN_Classifier, MNIST_Classifier
  from utils import Logger, Timer
label_desc: Use image node_id 2 for calling a global function with example usage: _maybe_train_or_load_digit_classifier_img(path, epochs) and returns: mnist_net,  svhn_net