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"]
code: def __init__(
      self,
      pretrained: bool = True,
      config: Optional[Dict[str, Any]] = None,
  ) -> None:
      super().__init__()
      # Initialize some parameters
      self.config = default_detector_cfg if config is None else config
      self.grid_size = self.config["grid_size"]
      self.junc_detect_thresh = self.config.get(
          "detection_thresh", 1 / 65
      )
      self.max_num_junctions = self.config.get("max_num_junctions", 500)
  
      # Load the pre-trained model
      self.model = SOLD2Net(self.config)
      if pretrained:
          pretrained_dict = torch.hub.load_state_dict_from_url(
              urls["wireframe"], map_location=map_location_to_cpu
          )
          state_dict = self.adapt_state_dict(
              pretrained_dict["model_state_dict"]
          )
          self.model.load_state_dict(state_dict)
      self.eval()
  
      # Initialize the line detector
      self.line_detector_cfg = self.config["line_detector_cfg"]
      self.line_detector = LineSegmentDetectionModule(
          **self.config["line_detector_cfg"]
      )
  
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 1 to create a new SOLD2_detector object from inherited base classes: Module with example: obj = SOLD2_detector(pretrained, config)