code: def get_dnn_loss_as_anomaly_score(tensor_x, tensor_y, use_cuda=True):
      """
      train an MLP using Adam optimizer for 20 iteration on the training data provided
  
      :meta private:
      """
      BS = tensor_x.size(0)
      LR = 0.001
      max_epochs = 20
  
      model = MLPNet(
          dim_inp=1,
          dim_out=tensor_y.size(1),
          nhiddens=[400, 400, 400],
          bn=True,
      )
      if use_cuda:
          model = model.cuda()
      epoch = 0
  
      # optimizer = torch.optim.SGD(model.parameters(), lr=LR, momentum=0.9, weight_decay=0)
      optimizer = torch.optim.Adam(
          model.parameters(), lr=LR, weight_decay=1e-3
      )
  
      my_dataset = data.TensorDataset(
          tensor_x, tensor_y
      )  # create your datset
      my_dataloader = data.DataLoader(
          my_dataset,
          batch_size=BS,
          shuffle=False,
          num_workers=0,
          pin_memory=True,
      )
  
      # with tqdm.tqdm(total=max_epochs) as pbar:
      while epoch < max_epochs:
          # pbar.update(1)
          epoch += 1
          for x, y in my_dataloader:
              if use_cuda:
                  x, y = x.cuda(), y.cuda()
  
              y_ = model(x)
              loss = ((y - y_) ** 2).sum(1).mean()
  
              optimizer.zero_grad()
              loss.backward()
              optimizer.step()
  
      for x, y in my_dataloader:
          if use_cuda:
              x, y = x.cuda(), y.cuda()
          y_ = model(x)
          loss = ((y - y_) ** 2).sum(1).view(-1)
      return loss.data.view(-1).cpu().numpy()
  
imports: import logging
  import math
  import numpy
  import pandas
  from merlion.models.anomaly.base import DetectorConfig, DetectorBase
  from merlion.post_process.threshold import AdaptiveAggregateAlarms
  from merlion.transform.moving_average import DifferenceTransform
  from merlion.utils import UnivariateTimeSeries, TimeSeries, to_timestamp
label_desc: Use image node_id 2 for calling a global function with example usage: get_dnn_loss_as_anomaly_score(tensor_x, tensor_y, use_cuda) and returns: loss