code: def _get_lazy_distance_matrix(
      desc1: Tensor, desc2: Tensor, dm_: Optional[Tensor] = None
  ) -> Tensor:
      """Helper function, which checks validity of provided distance matrix, or calculates L2-distance matrix dm is
      not provided.
  
      Args:
          desc1: Batch of descriptors of a shape :math:`(B1, D)`.
          desc2: Batch of descriptors of a shape :math:`(B2, D)`.
          dm: Tensor containing the distances from each descriptor in desc1
            to each descriptor in desc2, shape of :math:`(B1, B2)`.
      """
      if dm_ is None:
          dm = _cdist(desc1, desc2)
      else:
          KORNIA_CHECK_DM_DESC(desc1, desc2, dm_)
          dm = dm_
      return dm
  
imports: from typing import Any, ClassVar, Dict, List, Optional, Tuple
  import torch
  from kornia.core import Module, Tensor, concatenate
  from kornia.core.check import KORNIA_CHECK_DM_DESC, KORNIA_CHECK_SHAPE
  from kornia.feature.laf import get_laf_center
  from kornia.testing import is_mps_tensor_safe
  from .adalam import get_adalam_default_config, match_adalam
label_desc: Use image node_id 3 for calling a global function with example usage: _get_lazy_distance_matrix(desc1, desc2, dm_) and returns: dm