class_docstr: Implement RetinaNet in :paper:`RetinaNet`.
class_docstr_tok: ["Implement","RetinaNet","in",":","paper",":","`","RetinaNet","`","."]
docstr: NOTE: this interface is experimental.
  
  Args:
      backbone: a backbone module, must follow detectron2's backbone interface
      head (nn.Module): a module that predicts logits and regression deltas
          for each level from a list of per-level features
      head_in_features (Tuple[str]): Names of the input feature maps to be used in head
      anchor_generator (nn.Module): a module that creates anchors from a
          list of features. Usually an instance of :class:`AnchorGenerator`
      box2box_transform (Box2BoxTransform): defines the transform from anchors boxes to
          instance boxes
      anchor_matcher (Matcher): label the anchors by matching them with ground truth.
      num_classes (int): number of classes. Used to label background proposals.
  
      # Loss parameters:
      focal_loss_alpha (float): focal_loss_alpha
      focal_loss_gamma (float): focal_loss_gamma
      smooth_l1_beta (float): smooth_l1_beta
      box_reg_loss_type (str): Options are "smooth_l1", "giou", "diou", "ciou"
  
      # Inference parameters:
      test_score_thresh (float): Inference cls score threshold, only anchors with
          score > INFERENCE_TH are considered for inference (to improve speed)
      test_topk_candidates (int): Select topk candidates before NMS
      test_nms_thresh (float): Overlap threshold used for non-maximum suppression
          (suppress boxes with IoU >= this threshold)
      max_detections_per_image (int):
          Maximum number of detections to return per image during inference
          (100 is based on the limit established for the COCO dataset).
  
      pixel_mean, pixel_std: see :class:`DenseDetector`.
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","backbone",":","a","backbone","module",",","must","follow","detectron2","'s","backbone","interface","head","(","nn.Module",")",":","a","module","that","predicts","logits","and","regression","deltas","for","each","level","from","a","list","of","per-level","features","head_in_features","(","Tuple","[","str","]",")",":","Names","of","the","input","feature","maps","to","be","used","in","head","anchor_generator","(","nn.Module",")",":","a","module","that","creates","anchors","from","a","list","of","features",".","Usually","an","instance","of",":","class",":","`","AnchorGenerator","`","box2box_transform","(","Box2BoxTransform",")",":","defines","the","transform","from","anchors","boxes","to","instance","boxes","anchor_matcher","(","Matcher",")",":","label","the","anchors","by","matching","them","with","ground","truth",".","num_classes","(","int",")",":","number","of","classes",".","Used","to","label","background","proposals",".","#","Loss","parameters",":","focal_loss_alpha","(","float",")",":","focal_loss_alpha","focal_loss_gamma","(","float",")",":","focal_loss_gamma","smooth_l1_beta","(","float",")",":","smooth_l1_beta","box_reg_loss_type","(","str",")",":","Options","are","``","smooth_l1","''",",","``","giou","''",",","``","diou","''",",","``","ciou","''","#","Inference","parameters",":","test_score_thresh","(","float",")",":","Inference","cls","score","threshold",",","only","anchors","with","score",">","INFERENCE_TH","are","considered","for","inference","(","to","improve","speed",")","test_topk_candidates","(","int",")",":","Select","topk","candidates","before","NMS","test_nms_thresh","(","float",")",":","Overlap","threshold","used","for","non-maximum","suppression","(","suppress","boxes","with","IoU",">","=","this","threshold",")","max_detections_per_image","(","int",")",":","Maximum","number","of","detections","to","return","per","image","during","inference","(","100","is","based","on","the","limit","established","for","the","COCO","dataset",")",".","pixel_mean",",","pixel_std",":","see",":","class",":","`","DenseDetector","`","."]
code: def __init__(
      self,
      *,
      backbone: Backbone,
      head: nn.Module,
      head_in_features,
      anchor_generator,
      box2box_transform,
      anchor_matcher,
      num_classes,
      focal_loss_alpha=0.25,
      focal_loss_gamma=2.0,
      smooth_l1_beta=0.0,
      box_reg_loss_type="smooth_l1",
      test_score_thresh=0.05,
      test_topk_candidates=1000,
      test_nms_thresh=0.5,
      max_detections_per_image=100,
      pixel_mean,
      pixel_std,
      vis_period=0,
      input_format="BGR",
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          backbone: a backbone module, must follow detectron2's backbone interface
          head (nn.Module): a module that predicts logits and regression deltas
              for each level from a list of per-level features
          head_in_features (Tuple[str]): Names of the input feature maps to be used in head
          anchor_generator (nn.Module): a module that creates anchors from a
              list of features. Usually an instance of :class:`AnchorGenerator`
          box2box_transform (Box2BoxTransform): defines the transform from anchors boxes to
              instance boxes
          anchor_matcher (Matcher): label the anchors by matching them with ground truth.
          num_classes (int): number of classes. Used to label background proposals.
  
          # Loss parameters:
          focal_loss_alpha (float): focal_loss_alpha
          focal_loss_gamma (float): focal_loss_gamma
          smooth_l1_beta (float): smooth_l1_beta
          box_reg_loss_type (str): Options are "smooth_l1", "giou", "diou", "ciou"
  
          # Inference parameters:
          test_score_thresh (float): Inference cls score threshold, only anchors with
              score > INFERENCE_TH are considered for inference (to improve speed)
          test_topk_candidates (int): Select topk candidates before NMS
          test_nms_thresh (float): Overlap threshold used for non-maximum suppression
              (suppress boxes with IoU >= this threshold)
          max_detections_per_image (int):
              Maximum number of detections to return per image during inference
              (100 is based on the limit established for the COCO dataset).
  
          pixel_mean, pixel_std: see :class:`DenseDetector`.
      """
      super().__init__(
          backbone,
          head,
          head_in_features,
          pixel_mean=pixel_mean,
          pixel_std=pixel_std,
      )
      self.num_classes = num_classes
  
      # Anchors
      self.anchor_generator = anchor_generator
      self.box2box_transform = box2box_transform
      self.anchor_matcher = anchor_matcher
  
      # Loss parameters:
      self.focal_loss_alpha = focal_loss_alpha
      self.focal_loss_gamma = focal_loss_gamma
      self.smooth_l1_beta = smooth_l1_beta
      self.box_reg_loss_type = box_reg_loss_type
      # Inference parameters:
      self.test_score_thresh = test_score_thresh
      self.test_topk_candidates = test_topk_candidates
      self.test_nms_thresh = test_nms_thresh
      self.max_detections_per_image = max_detections_per_image
      # Vis parameters
      self.vis_period = vis_period
      self.input_format = input_format
  
imports: import logging
  import math
  from typing import List, Tuple
  import torch
  from fvcore.nn import sigmoid_focal_loss_jit
  from torch import Tensor, nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.layers import CycleBatchNormList, ShapeSpec, batched_nms, cat, get_norm
  from detectron2.structures import Boxes, ImageList, Instances, pairwise_iou
  from detectron2.utils.events import get_event_storage
  from ..anchor_generator import build_anchor_generator
  from ..backbone import Backbone, build_backbone
  from ..box_regression import Box2BoxTransform, _dense_box_regression_loss
  from ..matcher import Matcher
  from .build import META_ARCH_REGISTRY
  from .dense_detector import DenseDetector, permute_to_N_HWA_K
label_desc: Use image node_id 1 to create a new RetinaNet object from inherited base classes: DenseDetector with example: obj = RetinaNet()