code: def cdist(
      x1, x2, p=2.0, compute_mode="use_mm_for_euclid_dist_if_necessary"
  ):
      # type: (Tensor, Tensor, float, str) -> (Tensor)
      r"""Computes batched the p-norm distance between each pair of the two collections of row vectors.
  
      Args:
          x1 (Tensor): input tensor of shape :math:`B \times P \times M`.
          x2 (Tensor): input tensor of shape :math:`B \times R \times M`.
          p: p value for the p-norm distance to calculate between each vector pair
              :math:`\in [0, \infty]`.
          compute_mode:
              'use_mm_for_euclid_dist_if_necessary' - will use matrix multiplication approach to calculate
              euclidean distance (p = 2) if P > 25 or R > 25
              'use_mm_for_euclid_dist' - will always use matrix multiplication approach to calculate
              euclidean distance (p = 2)
              'donot_use_mm_for_euclid_dist' - will never use matrix multiplication approach to calculate
              euclidean distance (p = 2)
              Default: use_mm_for_euclid_dist_if_necessary.
  
      If x1 has shape :math:`B \times P \times M` and x2 has shape :math:`B \times R \times M` then the
      output will have shape :math:`B \times P \times R`.
  
      This function is equivalent to `scipy.spatial.distance.cdist(input,'minkowski', p=p)`
      if :math:`p \in (0, \infty)`. When :math:`p = 0` it is equivalent to
      `scipy.spatial.distance.cdist(input, 'hamming') * M`. When :math:`p = \infty`, the closest
      scipy function is `scipy.spatial.distance.cdist(xn, lambda x, y: np.abs(x - y).max())`.
  
      Example:
  
          >>> a = torch.tensor([[0.9041,  0.0196], [-0.3108, -2.4423], [-0.4821,  1.059]])
          >>> a
          tensor([[ 0.9041,  0.0196],
                  [-0.3108, -2.4423],
                  [-0.4821,  1.0590]])
          >>> b = torch.tensor([[-2.1763, -0.4713], [-0.6986,  1.3702]])
          >>> b
          tensor([[-2.1763, -0.4713],
                  [-0.6986,  1.3702]])
          >>> torch.cdist(a, b, p=2)
          tensor([[3.1193, 2.0959],
                  [2.7138, 3.8322],
                  [2.2830, 0.3791]])
      """
      if has_torch_function_variadic(x1, x2):
          return handle_torch_function(
              cdist, (x1, x2), x1, x2, p=p, compute_mode=compute_mode
          )
      if compute_mode == "use_mm_for_euclid_dist_if_necessary":
          return _VF.cdist(x1, x2, p, None)  # type: ignore[attr-defined]
      elif compute_mode == "use_mm_for_euclid_dist":
          return _VF.cdist(x1, x2, p, 1)  # type: ignore[attr-defined]
      elif compute_mode == "donot_use_mm_for_euclid_dist":
          return _VF.cdist(x1, x2, p, 2)  # type: ignore[attr-defined]
      else:
          raise ValueError(
              f"{compute_mode} is not a valid value for compute_mode"
          )
  
imports: from typing import List, Tuple, Optional, Union, Any, Sequence, TYPE_CHECKING
  import operator
  import itertools
  import torch
  from torch._C import _add_docstr
  import torch.nn.functional
  from ._lowrank import svd_lowrank, pca_lowrank
  from .overrides import has_torch_function, has_torch_function_unary, has_torch_function_variadic, handle_torch_function
  from ._jit_internal import boolean_dispatch
  from ._jit_internal import _overload
  from torch import _VF
label_desc: Use image node_id 18 for calling a global function with example usage: cdist(x1, x2, p, compute_mode) and returns: handle_torch_function, _VF, _VF, _VF