class_docstr: Implement FCOS in :paper:`fcos`.
class_docstr_tok: ["Implement","FCOS","in",":","paper",":","`","fcos","`","."]
code: def forward_inference(
      self,
      images: ImageList,
      features: List[torch.Tensor],
      predictions: List[List[torch.Tensor]],
  ):
      (
          pred_logits,
          pred_anchor_deltas,
          pred_centerness,
      ) = self._transpose_dense_predictions(
          predictions, [self.num_classes, 4, 1]
      )
      anchors = self.anchor_generator(features)
  
      results: List[Instances] = []
      for img_idx, image_size in enumerate(images.image_sizes):
          scores_per_image = [
              # Multiply and sqrt centerness & classification scores
              # (See eqn. 4 in https://arxiv.org/abs/2006.09214)
              torch.sqrt(x[img_idx].sigmoid_() * y[img_idx].sigmoid_())
              for x, y in zip(pred_logits, pred_centerness)
          ]
          deltas_per_image = [x[img_idx] for x in pred_anchor_deltas]
          results_per_image = self.inference_single_image(
              anchors, scores_per_image, deltas_per_image, image_size
          )
          results.append(results_per_image)
      return results
  
imports: import logging
  from typing import List, Optional, Tuple
  import torch
  from fvcore.nn import sigmoid_focal_loss_jit
  from torch import nn
  from torch.nn import functional
  from detectron2.layers import ShapeSpec, batched_nms
  from detectron2.structures import Boxes, ImageList, Instances, pairwise_point_box_distance
  from detectron2.utils.events import get_event_storage
  from ..anchor_generator import DefaultAnchorGenerator
  from ..backbone import Backbone
  from ..box_regression import Box2BoxTransformLinear, _dense_box_regression_loss
  from .dense_detector import DenseDetector
  from .retinanet import RetinaNetHead
label_desc: Use image node_id 7 for calling the FCOS obj's underlying member method code with example usage: obj.forward_inference(images, features, predictions) and returns: results