code: def estimated_coherence(
      S: npt.NDArray, eps: float = 1e-16
  ) -> npt.NDArray:
      """Estimate complex-valued coherence for the input STFT-domain signal.
  
      Args:
          S: STFT of the signal with shape (num_subbands, num_frames, num_channels)
          eps: small regularization constant
  
      Returns:
          Estimated coherence with shape (num_subbands, num_channels, num_channels)
      """
      if S.ndim != 3:
          raise RuntimeError(
              "Expecting the input STFT to be a 3D array"
          )
  
      num_subbands, num_frames, num_channels = S.shape
  
      if num_channels < 2:
          raise ValueError("Expecting at least 2 microphones")
  
      psd = np.mean(np.abs(S) ** 2, axis=1)
      estimated_coherence = np.zeros(
          (num_subbands, num_channels, num_channels), dtype=complex
      )
  
      for p in range(num_channels):
          estimated_coherence[:, p, p] = 1.0
          for q in range(p + 1, num_channels):
              cross_psd = np.mean(
                  S[:, :, p] * np.conjugate(S[:, :, q]), axis=1
              )
              estimated_coherence[:, p, q] = cross_psd / np.sqrt(
                  psd[:, p] * psd[:, q] + eps
              )
              # symmetry
              estimated_coherence[:, q, p] = np.conjugate(
                  estimated_coherence[:, p, q]
              )
  
      return estimated_coherence
  
imports: import math
  from typing import Iterable, Optional, Union
  import librosa
  import numpy
  import numpy.typing
  import scipy
  import soundfile
  import torch
  from scipy.spatial.distance import pdist, squareform
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling a global function with example usage: estimated_coherence(S, eps) and returns: estimated_coherence