code: def _sigma_median_diag(
      x: tf.Tensor, y: tf.Tensor, dist: tf.Tensor
  ) -> tf.Tensor:
      """
      Private version of the bandwidth estimation function :py:func:`~alibi_detect.utils.tensorflow.kernels.sigma_median`,
      with the +n (and -1) term excluded to account for the diagonal of the kernel matrix.
  
      Parameters
      ----------
      x
          Tensor of instances with dimension [Nx, features].
      y
          Tensor of instances with dimension [Ny, features].
      dist
          Tensor with dimensions [Nx, Ny], containing the pairwise distances between `x` and `y`.
  
      Returns
      -------
      The computed bandwidth, `sigma`.
      """
      n_median = tf.math.reduce_prod(dist.shape) // 2
      sigma = tf.expand_dims(
          (0.5 * tf.sort(tf.reshape(dist, (-1,)))[n_median]) ** 0.5,
          axis=0,
      )
      return sigma
  
file_path: alibi-detect/alibi_detect/cd/tensorflow/context_aware.py
imports: import logging
  import numpy
  import tensorflow
  import tensorflow_probability
  from typing import Callable, Dict, Optional, Tuple, Union, List
  from alibi_detect.cd.base import BaseContextMMDDrift
  from alibi_detect.utils.tensorflow.kernels import GaussianRBF
  from alibi_detect.utils.warnings import deprecated_alias
  from alibi_detect.utils.frameworks import Framework
  from alibi_detect.cd._domain_clf import _SVCDomainClf
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling a global function with example usage: _sigma_median_diag(x, y, dist) and returns: sigma