code: def _train_autoencoder(self, train_loader):
      optimizer = torch.optim.Adam(
          self.model.parameters(),
          lr=self.learning_rate,
          weight_decay=self.weight_decay,
      )
  
      self.best_loss = float("inf")
      self.best_model_dict = None
  
      for epoch in range(self.epochs):
          overall_loss = []
          for data, data_idx in train_loader:
              # print(epoch, data.shape)
              data = data.to(self.device).float()
              # print(data.shape)
              loss = criterion(data, self.model(data))
              # print('epoch {epoch} '.format(epoch=epoch), loss.item())
  
              self.model.zero_grad()
              loss.backward()
              optimizer.step()
              overall_loss.append(loss.item())
              # print(loss.item())
          print(
              "epoch {epoch}: training loss {train_loss} ".format(
                  epoch=epoch, train_loss=np.mean(overall_loss)
              )
          )
  
          # track the best model so far
          if np.mean(overall_loss) <= self.best_loss:
              # print("epoch {ep} is the current best; loss={loss}".format(ep=epoch, loss=np.mean(overall_loss)))
              self.best_loss = np.mean(overall_loss)
              self.best_model_dict = self.model.state_dict()
  
imports: from __future__ import division
  from __future__ import print_function
  import torch
  import numpy
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from pyod.utils.utility import check_parameter
  from pyod.utils.stat_models import pairwise_distances_no_broadcast
  from pyod.models.base import BaseDetector
  from pyod.utils.data import generate_data
  from pyod.utils.stat_models import pairwise_distances_no_broadcast
  from torch import nn
  from torchvision import transforms
label_desc: Use image node_id 3 for calling the AutoEncoder obj's underlying member method code with example usage: obj._train_autoencoder(train_loader) without return types