code: def ks_two_sample_multi_dim(
      x: torch.Tensor, y: torch.Tensor
  ) -> torch.Tensor:
      """Computes the two-sample two-sided Kolmorogov-Smirnov statistic.
  
      The inputs `x` and `y` are expected to be 2-dimensional tensors,
      the first dimensions being batch (potentially different) and the second
      features (necessarily the same).
  
      We return a one-dimensional tensor of KS scores D, one per dimension.
      """
      n_x, n_features = x.shape
      n_y, n_features_y = y.shape
      torchdrift.utils.check(
          n_features == n_features_y, "feature dimension mismatch"
      )
  
      joint_sorted = torch.argsort(torch.cat([x, y], dim=0), dim=0)
      sign = (joint_sorted < n_x).to(dtype=torch.float) * (
          1 / (n_x) + 1 / (n_y)
      ) - (1 / (n_y))
      ks_scores = sign.cumsum(0).abs().max(0).values
      return ks_scores
  
file_path: TorchDrift/torchdrift/detectors/ks.py
imports: from typing import Optional
  import torch
  import numpy
  from .None import Detector
  import torchdrift.utils
label_desc: Use image node_id 2 for calling a global function with example usage: ks_two_sample_multi_dim(x, y) and returns: ks_scores