code: def compute_frechet_distance(
      mu_x: torch.Tensor,
      sigma_x: torch.Tensor,
      mu_y: torch.Tensor,
      sigma_y: torch.Tensor,
      epsilon: float = 1e-6,
  ) -> torch.Tensor:
      """The Frechet distance between multivariate normal distributions."""
      diff = mu_x - mu_y
  
      covmean = _sqrtm(sigma_x.mm(sigma_y))
  
      # Product might be almost singular
      if not torch.isfinite(covmean).all():
          print(
              f"FID calculation produces singular product; adding {epsilon} to diagonal of covariance estimates"
          )
          offset = (
              torch.eye(
                  sigma_x.size(0), device=mu_x.device, dtype=mu_x.dtype
              )
              * epsilon
          )
          covmean = _sqrtm((sigma_x + offset).mm(sigma_y + offset))
  
      # Numerical error might give slight imaginary component
      if torch.is_complex(covmean):
          if not torch.allclose(
              torch.diagonal(covmean).imag,
              torch.tensor(0, dtype=torch.double),
              atol=1e-3,
          ):
              raise ValueError(
                  f"Imaginary component {torch.max(torch.abs(covmean.imag))} too high."
              )
          covmean = covmean.real
  
      tr_covmean = torch.trace(covmean)
      return (
          diff.dot(diff)
          + torch.trace(sigma_x)
          + torch.trace(sigma_y)
          - 2 * tr_covmean
      )
  
file_path: MONAI/monai/metrics/fid.py
imports: from __future__ import annotations
  import numpy
  import torch
  from monai.metrics.metric import Metric
  from monai.utils import optional_import
label_desc: Use image node_id 4 for calling a global function with example usage: compute_frechet_distance(mu_x, sigma_x, mu_y, sigma_y, epsilon) and returns: unknown