code: def resnet_fpn_backbone(
      *,
      backbone_name: str,
      weights: Optional[WeightsEnum],
      norm_layer: Callable[
          ..., nn.Module
      ] = misc_nn_ops.FrozenBatchNorm2d,
      trainable_layers: int = 3,
      returned_layers: Optional[List[int]] = None,
      extra_blocks: Optional[ExtraFPNBlock] = None,
  ) -> BackboneWithFPN:
      """
      Constructs a specified ResNet backbone with FPN on top. Freezes the specified number of layers in the backbone.
  
      Examples::
  
          >>> import torch
          >>> from torchvision.models import ResNet50_Weights
          >>> from torchvision.models.detection.backbone_utils import resnet_fpn_backbone
          >>> backbone = resnet_fpn_backbone(backbone_name='resnet50', weights=ResNet50_Weights.DEFAULT, trainable_layers=3)
          >>> # get some dummy image
          >>> x = torch.rand(1,3,64,64)
          >>> # compute the output
          >>> output = backbone(x)
          >>> print([(k, v.shape) for k, v in output.items()])
          >>> # returns
          >>>   [('0', torch.Size([1, 256, 16, 16])),
          >>>    ('1', torch.Size([1, 256, 8, 8])),
          >>>    ('2', torch.Size([1, 256, 4, 4])),
          >>>    ('3', torch.Size([1, 256, 2, 2])),
          >>>    ('pool', torch.Size([1, 256, 1, 1]))]
  
      Args:
          backbone_name (string): resnet architecture. Possible values are 'resnet18', 'resnet34', 'resnet50',
               'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'wide_resnet50_2', 'wide_resnet101_2'
          weights (WeightsEnum, optional): The pretrained weights for the model
          norm_layer (callable): it is recommended to use the default value. For details visit:
              (https://github.com/facebookresearch/maskrcnn-benchmark/issues/267)
          trainable_layers (int): number of trainable (not frozen) layers starting from final block.
              Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable.
          returned_layers (list of int): The layers of the network to return. Each entry must be in ``[1, 4]``.
              By default, all layers are returned.
          extra_blocks (ExtraFPNBlock or None): if provided, extra operations will
              be performed. It is expected to take the fpn features, the original
              features and the names of the original features as input, and returns
              a new list of feature maps and their corresponding names. By
              default, a ``LastLevelMaxPool`` is used.
      """
      backbone = resnet.__dict__[backbone_name](
          weights=weights, norm_layer=norm_layer
      )
      return _resnet_fpn_extractor(
          backbone, trainable_layers, returned_layers, extra_blocks
      )
  
file_path: vision/torchvision/models/detection/backbone_utils.py
imports: import warnings
  from typing import Callable, Dict, List, Optional, Union
  from torch import nn, Tensor
  from torchvision.ops import misc
  from torchvision.ops.feature_pyramid_network import ExtraFPNBlock, FeaturePyramidNetwork, LastLevelMaxPool
  from ..None import mobilenet, resnet
  from .._api import _get_enum_from_fn, WeightsEnum
  from .._utils import handle_legacy_interface, IntermediateLayerGetter
label_desc: Use image node_id 1 for calling a global function with example usage: resnet_fpn_backbone() and returns: _resnet_fpn_extractor