code: def _validate(self, validation_loader, metric_name, metric_func=None):
      if not metric_name:
          assert (
              metric_func
          ), "You must input valid metric_func or metric_name"
          metric_name = metric_func.__name__
      self.model.eval()
      with torch.no_grad():
          yhat_list = []
          y_list = []
          for x_valid_batch, y_valid_batch in validation_loader:
              yhat_list.append(self.model(x_valid_batch).numpy())
              y_list.append(y_valid_batch.numpy())
          yhat = np.concatenate(yhat_list, axis=0)
          y = np.concatenate(y_list, axis=0)
      # val_loss = self.criterion(yhat, y)
      if metric_func:
          eval_result = metric_func(y, yhat)
      else:
          eval_result = Evaluator.evaluate(
              metric=metric_name,
              y_true=y,
              y_pred=yhat,
              multioutput="uniform_average",
          )
      return {metric_name: eval_result}
  
imports: import torch
  from torch.utils.data import TensorDataset, DataLoader
  import types
  import numpy
  import math
  import pandas
  import tempfile
  import os
  from zoo.orca.automl.model.abstract import BaseModel, ModelBuilder
  from zoo.orca.automl.metrics import Evaluator
  from zoo.orca.automl.pytorch_utils import LR_NAME, DEFAULT_LR
label_desc: Use image node_id 12 for calling the PytorchBaseModel obj's underlying member method code with example usage: obj._validate(validation_loader, metric_name, metric_func) and returns: dict