code: def sigma_median(
      x: torch.Tensor, y: torch.Tensor, dist: torch.Tensor
  ) -> torch.Tensor:
      """
      Bandwidth estimation using the median heuristic :cite:t:`Gretton2012`.
  
      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 = min(x.shape[0], y.shape[0])
      n = n if (x[:n] == y[:n]).all() and x.shape == y.shape else 0
      n_median = n + (np.prod(dist.shape) - n) // 2 - 1
      sigma = (
          0.5
          * dist.flatten()
          .sort()
          .values[int(n_median)]
          .unsqueeze(dim=-1)
      ) ** 0.5
      return sigma
  
imports: import numpy
  import torch
  from torch import nn
  from .None import distance
  from typing import Optional, Union, Callable
  from alibi_detect.utils.frameworks import Framework
label_desc: Use image node_id 1 for calling a global function with example usage: sigma_median(x, y, dist) and returns: sigma