code: def test_retina_detector_resnet_backbone_shape(
      self, input_param, input_shape
  ):
      returned_layers = [1]
      anchor_generator = AnchorGeneratorWithAnchorShape(
          feature_map_scales=(1, 2),
          base_anchor_shapes=((8,) * input_param["spatial_dims"],),
      )
      detector = retinanet_resnet50_fpn_detector(
          **input_param,
          anchor_generator=anchor_generator,
          returned_layers=returned_layers,
      )
  
      with eval_mode(detector):
          input_data = torch.randn(input_shape)
          result = detector.forward(input_data)
          assert len(result) == len(result)
  
          input_data = [
              torch.randn(input_shape[1:])
              for _ in range(random.randint(1, 9))
          ]
          result = detector.forward(input_data)
          assert len(result) == len(result)
  
      detector.set_atss_matcher()
      detector.set_hard_negative_sampler(10, 0.5)
      for num_gt_box in [
          0,
          3,
      ]:  # test for both empty and non-empty boxes
          gt_box_start = torch.randint(
              2, (num_gt_box, input_param["spatial_dims"])
          ).to(torch.float16)
          gt_box_end = gt_box_start + torch.randint(
              1, 10, (num_gt_box, input_param["spatial_dims"])
          )
          one_target = {
              "boxes": torch.cat((gt_box_start, gt_box_end), dim=1),
              "labels": torch.randint(
                  input_param["num_classes"], (num_gt_box,)
              ),
          }
          with train_mode(detector):
              input_data = torch.randn(input_shape)
              targets = [one_target] * len(input_data)
              result = detector.forward(input_data, targets)
  
              input_data = [
                  torch.randn(input_shape[1:])
                  for _ in range(random.randint(1, 9))
              ]
              targets = [one_target] * len(input_data)
              result = detector.forward(input_data, targets)
  
file_path: MONAI/tests/test_retinanet_detector.py
imports: from __future__ import annotations
  import random
  import unittest
  import torch
  from parameterized import parameterized
  from monai.apps.detection.networks.retinanet_detector import RetinaNetDetector, retinanet_resnet50_fpn_detector
  from monai.apps.detection.utils.anchor_utils import AnchorGeneratorWithAnchorShape
  from monai.networks import eval_mode, train_mode
  from monai.utils import optional_import
  from tests.utils import SkipIfBeforePyTorchVersion, skip_if_quick, test_script_save
label_desc: Use image node_id 1 for calling the TestRetinaNetDetector obj's underlying member method code with example usage: obj.test_retina_detector_resnet_backbone_shape(input_param, input_shape) without return types