import torch


def create_detr_backbone(name: str, pretrained: bool = True,):
    """
        Creates Detr Backbone for Detection.
        Args:
            name: Name of supported bacbone. Supported Backbones are
                  "resnet50", "resnet101", "resnet50_dc5", "resnet101_dc5"
            pretrained: If True, returns backbone pretrained on COCO Dataset.
    """
    if(name == "resnet50"):
        backbone = torch.hub.load('facebookresearch/detr', 'detr_resnet50', pretrained=pretrained)

    elif(name == "resnet101"):
        backbone = torch.hub.load('facebookresearch/detr', 'detr_resnet101', pretrained=pretrained)

    elif(name == "resnet50_dc5"):
        backbone = torch.hub.load('facebookresearch/detr', 'detr_resnet50_dc5', pretrained=pretrained)

    elif(name == "resnet101_dc5"):
        backbone = torch.hub.load('facebookresearch/detr', 'detr_resnet50_dc5', pretrained=pretrained)

    else:
        raise ValueError("Unuspported backbone")

    return backbone