src/transformers/models/detr/modeling_detr.py/DetrTimmConvEncoder/__init__
class DetrTimmConvEncoder:    def __init__(self, name: str, dilation: bool):
        super().__init__()

        kwargs = {}
        if dilation:
            kwargs["output_stride"] = 16

        requires_backends(self, ["timm"])

        backbone = create_model(name, pretrained=True, features_only=True, out_indices=(1, 2, 3, 4), **kwargs)
        # replace batch norm by frozen batch norm
        with torch.no_grad():
            replace_batch_norm(backbone)
        self.model = backbone
        self.intermediate_channel_sizes = self.model.feature_info.channels()

        if "resnet" in name:
            for name, parameter in self.model.named_parameters():
                if "layer2" not in name and "layer3" not in name and "layer4" not in name:
                    parameter.requires_grad_(False)