class_docstr: Class matching two sets of line segments with the Needleman-Wunsch algorithm.
  
  TODO: move it later in kornia.feature.matching
class_docstr_tok: ["Class","matching","two","sets","of","line","segments","with","the","Needleman-Wunsch","algorithm",".","TODO",":","move","it","later","in","kornia.feature.matching"]
docstr: Regularly sample points along each line segments, with a minimal distance between each point.
  
  Pad the remaining points.
  Inputs:
      line_seg: an Nx2x2 Tensor.
  Outputs:
      line_points: an N x num_samples x 2 Tensor.
      valid_points: a boolean N x num_samples Tensor.
docstr_tok: ["Regularly","sample","points","along","each","line","segments",",","with","a","minimal","distance","between","each","point",".","Pad","the","remaining","points",".","Inputs",":","line_seg",":","an","Nx2x2","Tensor",".","Outputs",":","line_points",":","an","N","x","num_samples","x","2","Tensor",".","valid_points",":","a","boolean","N","x","num_samples","Tensor","."]
code: def sample_line_points(
      self, line_seg: Tensor
  ) -> Tuple[Tensor, Tensor]:
      """Regularly sample points along each line segments, with a minimal distance between each point.
  
      Pad the remaining points.
      Inputs:
          line_seg: an Nx2x2 Tensor.
      Outputs:
          line_points: an N x num_samples x 2 Tensor.
          valid_points: a boolean N x num_samples Tensor.
      """
      KORNIA_CHECK_SHAPE(line_seg, ["N", "2", "2"])
      num_lines = len(line_seg)
      line_lengths = torch.norm(line_seg[:, 0] - line_seg[:, 1], dim=1)
      dev = line_seg.device
      # Sample the points separated by at least min_dist_pts along each line
      # The number of samples depends on the length of the line
      num_samples_lst = torch.clamp(
          torch.div(
              line_lengths, self.min_dist_pts, rounding_mode="floor"
          ),
          2,
          self.num_samples,
      ).int()
      line_points = torch.empty(
          (num_lines, self.num_samples, 2),
          dtype=torch.float,
          device=dev,
      )
      valid_points = torch.empty(
          (num_lines, self.num_samples), dtype=torch.bool, device=dev
      )
      for n_samp in range(2, self.num_samples + 1):
          # Consider all lines where we can fit up to n_samp points
          cur_mask = num_samples_lst == n_samp
          cur_line_seg = line_seg[cur_mask]
          line_points_x = batched_linspace(
              cur_line_seg[:, 0, 0],
              cur_line_seg[:, 1, 0],
              n_samp,
              dim=-1,
          )
          line_points_y = batched_linspace(
              cur_line_seg[:, 0, 1],
              cur_line_seg[:, 1, 1],
              n_samp,
              dim=-1,
          )
          cur_line_points = stack([line_points_x, line_points_y], -1)
  
          # Pad
          cur_line_points = pad(
              cur_line_points, (0, 0, 0, self.num_samples - n_samp)
          )
          cur_valid_points = torch.ones(
              len(cur_line_seg),
              self.num_samples,
              dtype=torch.bool,
              device=dev,
          )
          cur_valid_points[:, n_samp:] = False
  
          line_points[cur_mask] = cur_line_points
          valid_points[cur_mask] = cur_valid_points
  
      return line_points, valid_points
  
imports: from typing import Any, Dict, Optional, Tuple
  import torch
  import torch.nn.functional
  from kornia.core import Module, Tensor, concatenate, pad, stack
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.geometry.conversions import normalize_pixel_coordinates
  from kornia.utils import map_location_to_cpu
  from .backbones import SOLD2Net
  from .sold2_detector import LineSegmentDetectionModule, line_map_to_segments, prob_to_junctions
label_desc: Use image node_id 3 for calling the WunschLineMatcher obj's underlying member method code with example usage: obj.sample_line_points(line_seg) and returns: line_points,  valid_points