class_docstr: Base class for classification models using neural network, based on PyTorch Lightning wrapper. The forward pass
  and loss computation must be implemented if new trainers inherit from this class. The basic workflow is defined
  in this class as follows. Every training/validation/testing procedure will call `compute_loss()` to compute the
  loss and log the output metrics. The `compute_loss()` function will call `forward()` to generate the output feature
  using the neural networks.
  
  Args:
      optimizer (dict, None): optimizer parameters.
      max_epochs (int): maximum number of epochs.
      init_lr (float): initial learning rate. Defaults to 0.001.
      adapt_lr (bool): whether to use the schedule for the learning rate. Defaults to False.
docstr: Compute loss for a given batch.
  
  Args:
      batch (tuple): batches returned by dataloader.
      split_name (str, optional): learning stage (one of ["train", "valid", "test"]).
          Defaults to "valid" for validation. "train" is for training and "test" for testing. This is currently
          used only for naming the metrics used for logging.
  
  Returns:
      loss (torch.Tensor): loss value.
      log_metrics (dict): dictionary of metrics to be logged. This is needed when using PyKale logging, but not
          mandatory when using PyTorch Lightning logging.
docstr_tok: ["Compute","loss","for","a","given","batch",".","Args",":","batch","(","tuple",")",":","batches","returned","by","dataloader",".","split_name","(","str",",","optional",")",":","learning","stage","(","one","of","[","``","train","''",",","``","valid","''",",","``","test","''","]",")",".","Defaults","to","``","valid","''","for","validation",".","``","train","''","is","for","training","and","``","test","''","for","testing",".","This","is","currently","used","only","for","naming","the","metrics","used","for","logging",".","Returns",":","loss","(","torch.Tensor",")",":","loss","value",".","log_metrics","(","dict",")",":","dictionary","of","metrics","to","be","logged",".","This","is","needed","when","using","PyKale","logging",",","but","not","mandatory","when","using","PyTorch","Lightning","logging","."]
code: def compute_loss(self, batch, split_name="valid"):
      """Compute loss for a given batch.
  
      Args:
          batch (tuple): batches returned by dataloader.
          split_name (str, optional): learning stage (one of ["train", "valid", "test"]).
              Defaults to "valid" for validation. "train" is for training and "test" for testing. This is currently
              used only for naming the metrics used for logging.
  
      Returns:
          loss (torch.Tensor): loss value.
          log_metrics (dict): dictionary of metrics to be logged. This is needed when using PyKale logging, but not
              mandatory when using PyTorch Lightning logging.
      """
      raise NotImplementedError("Loss function needs to be defined.")
  
imports: import pytorch_lightning
  import torch
  import torch.nn
  from sklearn.metrics import accuracy_score
  from kale.predict import losses
label_desc: Use image node_id 3 for calling the BaseNNTrainer obj's underlying member method code with example usage: obj.compute_loss(batch, split_name) without return types