class_docstr: Domain independent network (DIN). It is under development and will be updated with references later.
code: def compute_loss(self, batch, split_name="valid"):
      x, y, domain_labels = batch
      phi_x = self.forward(x)
      loss_dist = self._compute_domain_dist(phi_x, domain_labels)
      src_idx = torch.where(domain_labels != self.target_label)[0]
      tgt_idx = torch.where(domain_labels == self.target_label)[0]
      cls_output = self.classifier(phi_x)
      loss_cls, ok_src = losses.cross_entropy_logits(
          cls_output[src_idx], y[src_idx]
      )
      _, ok_tgt = losses.cross_entropy_logits(
          cls_output[tgt_idx], y[tgt_idx]
      )
  
      ok_src = ok_src.double().mean()
      ok_tgt = ok_tgt.double().mean()
      task_loss = loss_cls
  
      log_metrics = {
          f"{split_name}_source_acc": ok_src,
          f"{split_name}_target_acc": ok_tgt,
          f"{split_name}_domain_acc": loss_dist,
      }
  
      return task_loss, loss_dist, log_metrics
  
imports: import torch
  import torch.nn
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.metrics.pairwise import pairwise_kernels
  from sklearn.preprocessing import LabelBinarizer
  from torch.linalg import multi_dot
  from torch.nn.functional import one_hot
  import kale.predict.losses
  from kale.embed.image_cnn import _Bottleneck
  from kale.pipeline.domain_adapter import BaseAdaptTrainer
label_desc: Use image node_id 2 for calling the _DINTrainer obj's underlying member method code with example usage: obj.compute_loss(batch, split_name) and returns: task_loss,  loss_dist,  log_metrics