code: def mahalanobis(embedding, mean, inv_covariance):
      B, C, H, W = embedding.shape
      delta = (
          (embedding - mean).reshape((B, C, H * W)).transpose((2, 0, 1))
      )
      distances = (
          ((delta @ inv_covariance) @ delta).sum(2).transpose((1, 0))
      )
      distances = distances.reshape((B, H, W))
      distances = distances.sqrt_()
      return distances
  
imports: import os
  import argparse
  import numpy
  import matplotlib
  import matplotlib.pyplot
  from sklearn.metrics import roc_curve, auc
  from tqdm import tqdm
  from skimage import measure, morphology
  from skimage.segmentation import mark_boundaries
  import paddle
label_desc: Use image node_id 4 for calling a global function with example usage: mahalanobis(embedding, mean, inv_covariance) and returns: distances