code: def linear_mmd(self, center_rgb, center_ir):
      def compute_dist_(x_rgb, x_ir):
          n = x_rgb.size(0)
          dist1 = (
              torch.pow(x_rgb, 2).sum(dim=1, keepdim=True).expand(n, n)
          )
          dist2 = (
              torch.pow(x_ir, 2).sum(dim=1, keepdim=True).expand(n, n)
          )
  
          dist = dist1 + dist2.t()
          dist.addmm_(mat1=x_rgb, mat2=x_ir.t(), beta=1, alpha=-2)
          dist = dist.clamp(min=1e-12)  # for numerical stability
          return dist
  
      matrix = compute_dist_(center_rgb, center_ir)
      loss = matrix.diag()
  
      return loss.mean()
  
file_path: insightface/recognition/idmmd/losses.py
imports: import torch
  from torch import nn
  import torch.nn.functional
label_desc: Use image node_id 4 for calling the IDMMD obj's underlying member method code with example usage: obj.linear_mmd(center_rgb, center_ir) and returns: loss, dist