class_docstr: Module, which detects line segments in an image.
  
  This is based on the original code from the paper "SOLD²: Self-supervised
  Occlusion-aware Line Detector and Descriptor". See :cite:`SOLD22021` for more details.
  
  Args:
      config: Dict specifying parameters. None will load the default parameters,
          which are tuned for images in the range 400~800 px.
      pretrained: If True, download and set pretrained weights to the model.
  
  Returns:
      The raw junction and line heatmaps, as well as the list of detected line segments (ij coordinates convention).
  
  Example:
      >>> img = torch.rand(1, 1, 512, 512)
      >>> sold2_detector = SOLD2_detector()
      >>> line_segments = sold2_detector(img)["line_segments"]
docstr: Args:
      img: batched images with shape :math:`(B, 1, H, W)`.
  
  Return:
      - ``line_segments``: list of N line segments in each of the B images :math:`List[(N, 2, 2)]`.
      - ``junction_heatmap``: raw junction heatmap of shape :math:`(B, H, W)`.
      - ``line_heatmap``: raw line heatmap of shape :math:`(B, H, W)`.
docstr_tok: ["Args",":","img",":","batched","images","with","shape",":","math",":","`","(","B",",","1",",","H",",","W",")","`",".","Return",":","-","``","line_segments","``",":","list","of","N","line","segments","in","each","of","the","B","images",":","math",":","`","List","[","(","N",",","2",",","2",")","]","`",".","-","``","junction_heatmap","``",":","raw","junction","heatmap","of","shape",":","math",":","`","(","B",",","H",",","W",")","`",".","-","``","line_heatmap","``",":","raw","line","heatmap","of","shape",":","math",":","`","(","B",",","H",",","W",")","`","."]
code: def forward(self, img: Tensor) -> Dict[str, Any]:
      """
      Args:
          img: batched images with shape :math:`(B, 1, H, W)`.
  
      Return:
          - ``line_segments``: list of N line segments in each of the B images :math:`List[(N, 2, 2)]`.
          - ``junction_heatmap``: raw junction heatmap of shape :math:`(B, H, W)`.
          - ``line_heatmap``: raw line heatmap of shape :math:`(B, H, W)`.
      """
      KORNIA_CHECK_SHAPE(img, ["B", "1", "H", "W"])
      outputs = {}
  
      # Forward pass of the CNN backbone
      net_outputs = self.model(img)
      outputs["junction_heatmap"] = net_outputs["junctions"]
      outputs["line_heatmap"] = net_outputs["heatmap"]
  
      # Loop through all images
      lines = []
      for junc_prob, heatmap in zip(
          net_outputs["junctions"], net_outputs["heatmap"]
      ):
          # Get the junctions
          junctions = prob_to_junctions(
              junc_prob,
              self.grid_size,
              self.junc_detect_thresh,
              self.max_num_junctions,
          )
  
          # Run the line detector
          line_map, junctions, _ = self.line_detector.detect(
              junctions, heatmap
          )
          lines.append(line_map_to_segments(junctions, line_map))
      outputs["line_segments"] = lines
  
      return outputs
  
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 3 for calling the SOLD2_detector obj's underlying member method code with example usage: obj.forward(img) and returns: outputs