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: Detection by bilinear sampling.
docstr_tok: ["Detection","by","bilinear","sampling","."]
code: def detect_bilinear(
      self, heatmap: Tensor, cand_h: Tensor, cand_w: Tensor
  ) -> Tensor:
      """Detection by bilinear sampling."""
      # Get the floor and ceiling locations
      cand_h_floor = torch.floor(cand_h).to(torch.long)
      cand_h_ceil = torch.ceil(cand_h).to(torch.long)
      cand_w_floor = torch.floor(cand_w).to(torch.long)
      cand_w_ceil = torch.ceil(cand_w).to(torch.long)
  
      # Perform the bilinear sampling
      cand_samples_feat = (
          heatmap[cand_h_floor, cand_w_floor]
          * (cand_h_ceil - cand_h)
          * (cand_w_ceil - cand_w)
          + heatmap[cand_h_floor, cand_w_ceil]
          * (cand_h_ceil - cand_h)
          * (cand_w - cand_w_floor)
          + heatmap[cand_h_ceil, cand_w_floor]
          * (cand_h - cand_h_floor)
          * (cand_w_ceil - cand_w)
          + heatmap[cand_h_ceil, cand_w_ceil]
          * (cand_h - cand_h_floor)
          * (cand_w - cand_w_floor)
      )
  
      return cand_samples_feat
  
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 8 for calling the LineSegmentDetectionModule obj's underlying member method code with example usage: obj.detect_bilinear(heatmap, cand_h, cand_w) and returns: cand_samples_feat