code: def from_distance_maps(
      distance_maps: np.ndarray,
      inverted: bool,
      if_not_found_coords: Optional[Union[Sequence[int], dict]],
      threshold: Optional[float] = None,
  ) -> List[Tuple[float, float]]:
      """Convert outputs of ``to_distance_maps()`` to ``KeypointsOnImage``.
      This is the inverse of `to_distance_maps`.
  
      Args:
          distance_maps (np.ndarray): The distance maps. ``N`` is the number of keypoints.
          inverted (bool): Whether the given distance maps were generated in inverted mode
              (i.e. :func:`KeypointsOnImage.to_distance_maps` was called with ``inverted=True``) or in non-inverted mode.
          if_not_found_coords (tuple, list, dict or None, optional):
              Coordinates to use for keypoints that cannot be found in `distance_maps`.
  
              * If this is a ``list``/``tuple``, it must contain two ``int`` values.
              * If it is a ``dict``, it must contain the keys ``x`` and ``y`` with each containing one ``int`` value.
              * If this is ``None``, then the keypoint will not be added.
          threshold (float): The search for keypoints works by searching for the
              argmin (non-inverted) or argmax (inverted) in each channel. This
              parameters contains the maximum (non-inverted) or minimum (inverted) value to accept in order to view a hit
              as a keypoint. Use ``None`` to use no min/max.
          nb_channels (None, int): Number of channels of the image on which the keypoints are placed.
              Some keypoint augmenters require that information. If set to ``None``, the keypoint's shape will be set
              to ``(height, width)``, otherwise ``(height, width, nb_channels)``.
      """
      if distance_maps.ndim != 3:
          raise ValueError(
              f"Expected three-dimensional input, "
              f"got {distance_maps.ndim} dimensions and shape {distance_maps.shape}."
          )
      height, width, nb_keypoints = distance_maps.shape
  
      drop_if_not_found = False
      if if_not_found_coords is None:
          drop_if_not_found = True
          if_not_found_x = -1
          if_not_found_y = -1
      elif isinstance(if_not_found_coords, (tuple, list)):
          if len(if_not_found_coords) != 2:
              raise ValueError(
                  f"Expected tuple/list 'if_not_found_coords' to contain exactly two entries, "
                  f"got {len(if_not_found_coords)}."
              )
          if_not_found_x = if_not_found_coords[0]
          if_not_found_y = if_not_found_coords[1]
      elif isinstance(if_not_found_coords, dict):
          if_not_found_x = if_not_found_coords["x"]
          if_not_found_y = if_not_found_coords["y"]
      else:
          raise ValueError(
              f"Expected if_not_found_coords to be None or tuple or list or dict, got {type(if_not_found_coords)}."
          )
  
      keypoints = []
      for i in range(nb_keypoints):
          if inverted:
              hitidx_flat = np.argmax(distance_maps[..., i])
          else:
              hitidx_flat = np.argmin(distance_maps[..., i])
          hitidx_ndim = np.unravel_index(hitidx_flat, (height, width))
          if not inverted and threshold is not None:
              found = (
                  distance_maps[hitidx_ndim[0], hitidx_ndim[1], i]
                  < threshold
              )
          elif inverted and threshold is not None:
              found = (
                  distance_maps[hitidx_ndim[0], hitidx_ndim[1], i]
                  >= threshold
              )
          else:
              found = True
          if found:
              keypoints.append(
                  (float(hitidx_ndim[1]), float(hitidx_ndim[0]))
              )
          else:
              if not drop_if_not_found:
                  keypoints.append((if_not_found_x, if_not_found_y))
  
      return keypoints
  
imports: import math
  from typing import List, Optional, Sequence, Tuple, Union
  import cv2
  import numpy
  import skimage.transform
  from scipy.ndimage import gaussian_filter
  from albumentations.augmentations.utils import _maybe_process_in_chunks, angle_2pi_range, clipped, preserve_channel_dim, preserve_shape
  from ...None import random_utils
  from ...core.bbox_utils import denormalize_bbox, normalize_bbox
  from ...core.transforms_interface import BoxInternalType, FillValueType, ImageColorType, KeypointInternalType
label_desc: Use image node_id 30 for calling a global function with example usage: from_distance_maps(distance_maps, inverted, if_not_found_coords, threshold) and returns: keypoints