class_docstr: Moment matching for multi-source domain adaptation (M3SDA).
  
  Reference:
      Peng, X., Bai, Q., Xia, X., Huang, Z., Saenko, K., & Wang, B. (2019). Moment matching for multi-source
      domain adaptation. In Proceedings of the IEEE/CVF International Conference on Computer Vision
      (pp. 1406-1415).
      https://openaccess.thecvf.com/content_ICCV_2019/html/Peng_Moment_Matching_for_Multi-Source_Domain_Adaptation_ICCV_2019_paper.html
code: def compute_loss(self, batch, split_name="valid"):
      x, y, domain_labels = batch
      phi_x = self.forward(x)
      moment_loss = 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_loss, ok_src = self._compute_cls_loss(
          phi_x[src_idx], y[src_idx], domain_labels[src_idx]
      )
      if len(tgt_idx) > 0:
          y_tgt_hat = _average_cls_output(
              phi_x[tgt_idx], self.classifiers
          )
          _, ok_tgt = losses.cross_entropy_logits(y_tgt_hat, y[tgt_idx])
      else:
          ok_tgt = 0.0
  
      ok_src = ok_src.double().mean()
      ok_tgt = ok_tgt.double().mean()
      task_loss = cls_loss
  
      log_metrics = {
          f"{split_name}_source_acc": ok_src,
          f"{split_name}_target_acc": ok_tgt,
          f"{split_name}_domain_acc": moment_loss,
      }
  
      return task_loss, moment_loss, 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 M3SDATrainer obj's underlying member method code with example usage: obj.compute_loss(batch, split_name) and returns: task_loss,  moment_loss,  log_metrics