def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, trainable_backbone_layers=None, **kwargs):
    '\n    Constructs a Faster R-CNN model with a ResNet-50-FPN backbone.\n\n    Reference: `"Faster R-CNN: Towards Real-Time Object Detection with\n    Region Proposal Networks" <https://arxiv.org/abs/1506.01497>`_.\n\n    The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each\n    image, and should be in ``0-1`` range. Different images can have different sizes.\n\n    The behavior of the model changes depending if it is in training or evaluation mode.\n\n    During training, the model expects both the input tensors, as well as a targets (list of dictionary),\n    containing:\n\n        - boxes (``FloatTensor[N, 4]``): the ground-truth boxes in ``[x1, y1, x2, y2]`` format, with\n          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.\n        - labels (``Int64Tensor[N]``): the class label for each ground-truth box\n\n    The model returns a ``Dict[Tensor]`` during training, containing the classification and regression\n    losses for both the RPN and the R-CNN.\n\n    During inference, the model requires only the input tensors, and returns the post-processed\n    predictions as a ``List[Dict[Tensor]]``, one for each input image. The fields of the ``Dict`` are as\n    follows, where ``N`` is the number of detections:\n\n        - boxes (``FloatTensor[N, 4]``): the predicted boxes in ``[x1, y1, x2, y2]`` format, with\n          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.\n        - labels (``Int64Tensor[N]``): the predicted labels for each detection\n        - scores (``Tensor[N]``): the scores of each detection\n\n    For more details on the output, you may refer to :ref:`instance_seg_output`.\n\n    Faster R-CNN is exportable to ONNX for a fixed batch size with inputs images of fixed size.\n\n    Example::\n\n        >>> model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)\n        >>> # For training\n        >>> images, boxes = torch.rand(4, 3, 600, 1200), torch.rand(4, 11, 4)\n        >>> boxes[:, :, 2:4] = boxes[:, :, 0:2] + boxes[:, :, 2:4]\n        >>> labels = torch.randint(1, 91, (4, 11))\n        >>> images = list(image for image in images)\n        >>> targets = []\n        >>> for i in range(len(images)):\n        >>>     d = {}\n        >>>     d[\'boxes\'] = boxes[i]\n        >>>     d[\'labels\'] = labels[i]\n        >>>     targets.append(d)\n        >>> output = model(images, targets)\n        >>> # For inference\n        >>> model.eval()\n        >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]\n        >>> predictions = model(x)\n        >>>\n        >>> # optionally, if you want to export the model to ONNX:\n        >>> torch.onnx.export(model, x, "faster_rcnn.onnx", opset_version = 11)\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        pretrained_backbone (bool): If True, returns a model with backbone pre-trained on Imagenet\n        trainable_backbone_layers (int): number of trainable (not frozen) resnet layers starting from final block.\n            Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is\n            passed (the default) this value is set to 3.\n    '
    is_trained = (pretrained or pretrained_backbone)
    trainable_backbone_layers = _validate_trainable_layers(is_trained, trainable_backbone_layers, 5, 3)
    norm_layer = (misc_nn_ops.FrozenBatchNorm2d if is_trained else nn.BatchNorm2d)
    if pretrained:
        pretrained_backbone = False
    backbone = resnet50(pretrained=pretrained_backbone, progress=progress, norm_layer=norm_layer)
    backbone = _resnet_fpn_extractor(backbone, trainable_backbone_layers)
    model = FasterRCNN(backbone, num_classes, **kwargs)
    if pretrained:
        state_dict = load_state_dict_from_url(model_urls['fasterrcnn_resnet50_fpn_coco'], progress=progress)
        model.load_state_dict(state_dict)
        overwrite_eps(model, 0.0)
    return model
Constructs a Faster R-CNN model with a ResNet-50-FPN backbone.

Reference: `"Faster R-CNN: Towards Real-Time Object Detection with
Region Proposal Networks" <https://arxiv.org/abs/1506.01497>`_.

The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each
image, and should be in ``0-1`` range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:

    - boxes (``FloatTensor[N, 4]``): the ground-truth boxes in ``[x1, y1, x2, y2]`` format, with
      ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.
    - labels (``Int64Tensor[N]``): the class label for each ground-truth box

The model returns a ``Dict[Tensor]`` during training, containing the classification and regression
losses for both the RPN and the R-CNN.

During inference, the model requires only the input tensors, and returns the post-processed
predictions as a ``List[Dict[Tensor]]``, one for each input image. The fields of the ``Dict`` are as
follows, where ``N`` is the number of detections:

    - boxes (``FloatTensor[N, 4]``): the predicted boxes in ``[x1, y1, x2, y2]`` format, with
      ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.
    - labels (``Int64Tensor[N]``): the predicted labels for each detection
    - scores (``Tensor[N]``): the scores of each detection

For more details on the output, you may refer to :ref:`instance_seg_output`.

Faster R-CNN is exportable to ONNX for a fixed batch size with inputs images of fixed size.

Example::

    >>> model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
    >>> # For training
    >>> images, boxes = torch.rand(4, 3, 600, 1200), torch.rand(4, 11, 4)
    >>> boxes[:, :, 2:4] = boxes[:, :, 0:2] + boxes[:, :, 2:4]
    >>> labels = torch.randint(1, 91, (4, 11))
    >>> images = list(image for image in images)
    >>> targets = []
    >>> for i in range(len(images)):
    >>>     d = {}
    >>>     d['boxes'] = boxes[i]
    >>>     d['labels'] = labels[i]
    >>>     targets.append(d)
    >>> output = model(images, targets)
    >>> # For inference
    >>> model.eval()
    >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]
    >>> predictions = model(x)
    >>>
    >>> # optionally, if you want to export the model to ONNX:
    >>> torch.onnx.export(model, x, "faster_rcnn.onnx", opset_version = 11)

Args:
    pretrained (bool): If True, returns a model pre-trained on COCO train2017
    progress (bool): If True, displays a progress bar of the download to stderr
    num_classes (int): number of output classes of the model (including the background)
    pretrained_backbone (bool): If True, returns a model with backbone pre-trained on Imagenet
    trainable_backbone_layers (int): number of trainable (not frozen) resnet layers starting from final block.
        Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is
        passed (the default) this value is set to 3.
def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, trainable_backbone_layers=None, **kwargs):
    '\n    Constructs a Faster R-CNN model with a ResNet-50-FPN backbone.\n\n    Reference: `"Faster R-CNN: Towards Real-Time Object Detection with\n    Region Proposal Networks" <https://arxiv.org/abs/1506.01497>`_.\n\n    The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each\n    image, and should be in ``0-1`` range. Different images can have different sizes.\n\n    The behavior of the model changes depending if it is in training or evaluation mode.\n\n    During training, the model expects both the input tensors, as well as a targets (list of dictionary),\n    containing:\n\n        - boxes (``FloatTensor[N, 4]``): the ground-truth boxes in ``[x1, y1, x2, y2]`` format, with\n          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.\n        - labels (``Int64Tensor[N]``): the class label for each ground-truth box\n\n    The model returns a ``Dict[Tensor]`` during training, containing the classification and regression\n    losses for both the RPN and the R-CNN.\n\n    During inference, the model requires only the input tensors, and returns the post-processed\n    predictions as a ``List[Dict[Tensor]]``, one for each input image. The fields of the ``Dict`` are as\n    follows, where ``N`` is the number of detections:\n\n        - boxes (``FloatTensor[N, 4]``): the predicted boxes in ``[x1, y1, x2, y2]`` format, with\n          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.\n        - labels (``Int64Tensor[N]``): the predicted labels for each detection\n        - scores (``Tensor[N]``): the scores of each detection\n\n    For more details on the output, you may refer to :ref:`instance_seg_output`.\n\n    Faster R-CNN is exportable to ONNX for a fixed batch size with inputs images of fixed size.\n\n    Example::\n\n        >>> model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)\n        >>> # For training\n        >>> images, boxes = torch.rand(4, 3, 600, 1200), torch.rand(4, 11, 4)\n        >>> boxes[:, :, 2:4] = boxes[:, :, 0:2] + boxes[:, :, 2:4]\n        >>> labels = torch.randint(1, 91, (4, 11))\n        >>> images = list(image for image in images)\n        >>> targets = []\n        >>> for i in range(len(images)):\n        >>>     d = {}\n        >>>     d[\'boxes\'] = boxes[i]\n        >>>     d[\'labels\'] = labels[i]\n        >>>     targets.append(d)\n        >>> output = model(images, targets)\n        >>> # For inference\n        >>> model.eval()\n        >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]\n        >>> predictions = model(x)\n        >>>\n        >>> # optionally, if you want to export the model to ONNX:\n        >>> torch.onnx.export(model, x, "faster_rcnn.onnx", opset_version = 11)\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        pretrained_backbone (bool): If True, returns a model with backbone pre-trained on Imagenet\n        trainable_backbone_layers (int): number of trainable (not frozen) resnet layers starting from final block.\n            Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is\n            passed (the default) this value is set to 3.\n    '
    is_trained = (pretrained or pretrained_backbone)
    trainable_backbone_layers = _validate_trainable_layers(is_trained, trainable_backbone_layers, 5, 3)
    norm_layer = (misc_nn_ops.FrozenBatchNorm2d if is_trained else nn.BatchNorm2d)
    if pretrained:
        pretrained_backbone = False
    backbone = resnet50(pretrained=pretrained_backbone, progress=progress, norm_layer=norm_layer)
    backbone = _resnet_fpn_extractor(backbone, trainable_backbone_layers)
    model = FasterRCNN(backbone, num_classes, **kwargs)
    if pretrained:
        state_dict = load_state_dict_from_url(model_urls['fasterrcnn_resnet50_fpn_coco'], progress=progress)
        model.load_state_dict(state_dict)
        overwrite_eps(model, 0.0)
    return model