class_docstr: Module extracting line segments from junctions and line heatmaps.
  
  Args:
      detect_thresh: The probability threshold for mean activation (0. ~ 1.)
      num_samples: Number of sampling locations along the line segments.
      inlier_thresh: The min inlier ratio to satisfy (0. ~ 1.) => 0. means no threshold.
      heatmap_low_thresh: The lowest threshold for the pixel to be considered as candidate in junction recovery.
      heatmap_high_thresh: The higher threshold for NMS in junction recovery.
      max_local_patch_radius: The max patch to be considered in local maximum search.
      lambda_radius: The lambda factor in linear local maximum search formulation
      use_candidate_suppression: Apply candidate suppression to break long segments into short sub-segments.
      nms_dist_tolerance: The distance tolerance for nms. Decide whether the junctions are on the line.
      use_heatmap_refinement: Use heatmap refinement method or not.
      heatmap_refine_cfg: The configs for heatmap refinement methods.
      use_junction_refinement: Use junction refinement method or not.
      junction_refine_cfg: The configs for junction refinement methods.
docstr: Suppress overlapping long lines in the candidate segments.
docstr_tok: ["Suppress","overlapping","long","lines","in","the","candidate","segments","."]
code: def candidate_suppression(
      self, junctions: Tensor, candidate_map: Tensor
  ) -> Tensor:
      """Suppress overlapping long lines in the candidate segments."""
      # Define the distance tolerance
      dist_tolerance = self.nms_dist_tolerance
  
      # Compute distance between junction pairs
      # (num_junc x 1 x 2) - (1 x num_junc x 2) => num_junc x num_junc map
      line_dist_map = (
          torch.sum(
              (torch.unsqueeze(junctions, dim=1) - junctions[None, ...])
              ** 2,
              dim=-1,
          )
          ** 0.5
      )
  
      # Fetch all the "detected lines"
      seg_indexes = where(torch.triu(candidate_map, diagonal=1))
      start_point_idxs = seg_indexes[0]
      end_point_idxs = seg_indexes[1]
      start_points = junctions[start_point_idxs, :]
      end_points = junctions[end_point_idxs, :]
  
      # Fetch corresponding entries
      line_dists = line_dist_map[start_point_idxs, end_point_idxs]
  
      # Check whether they are on the line
      dir_vecs = (end_points - start_points) / torch.norm(
          end_points - start_points, dim=-1
      )[..., None]
      # Get the orthogonal distance
      cand_vecs = junctions[None, ...] - start_points.unsqueeze(dim=1)
      cand_vecs_norm = torch.norm(cand_vecs, dim=-1)
      # Check whether they are projected directly onto the segment
      proj = (
          torch.einsum("bij,bjk->bik", cand_vecs, dir_vecs[..., None])
          / line_dists[..., None, None]
      )
      # proj is num_segs x num_junction x 1
      proj_mask = (proj >= 0) * (proj <= 1)
      cand_angles = torch.acos(
          torch.einsum("bij,bjk->bik", cand_vecs, dir_vecs[..., None])
          / cand_vecs_norm[..., None]
      )
      cand_dists = cand_vecs_norm[..., None] * sin(cand_angles)
      junc_dist_mask = cand_dists <= dist_tolerance
      junc_mask = junc_dist_mask * proj_mask
  
      # Minus starting points
      num_segs = len(start_point_idxs)
      junc_counts = torch.sum(junc_mask, dim=[1, 2])
      junc_counts -= junc_mask[..., 0][
          torch.arange(0, num_segs), start_point_idxs
      ].to(torch.int)
      junc_counts -= junc_mask[..., 0][
          torch.arange(0, num_segs), end_point_idxs
      ].to(torch.int)
  
      # Get the invalid candidate mask
      final_mask = junc_counts > 0
      candidate_map[
          start_point_idxs[final_mask], end_point_idxs[final_mask]
      ] = 0
  
      return candidate_map
  
imports: import math
  from typing import Any, Dict, Optional, Tuple
  import torch
  from kornia.core import Module, Tensor, concatenate, sin, stack, tensor, where, zeros
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.geometry.bbox import nms
  from kornia.utils import map_location_to_cpu, torch_meshgrid
  from .backbones import SOLD2Net
label_desc: Use image node_id 5 for calling the LineSegmentDetectionModule obj's underlying member method code with example usage: obj.candidate_suppression(junctions, candidate_map) and returns: candidate_map