code: def build_backbone(config: omegaconf.DictConfig):
      """
      Difference between this and the build_backbone provided
      by detectron2 is as follows:
      - Different stem, include caffe_maxpool
      - Number of blocks is different, unconfigurable in detectron
      - Freeze-at operates differently in detectron
      """
      input_shape = ShapeSpec(channels=len(config.MODEL.PIXEL_MEAN))
      norm = config.MODEL.RESNETS.NORM
      stem = BasicStem(
          in_channels=input_shape.channels,
          out_channels=config.MODEL.RESNETS.STEM_OUT_CHANNELS,
          norm=norm,
          caffe_maxpool=config.MODEL.MAX_POOL,
      )
      freeze_at = config.MODEL.BACKBONE.FREEZE_AT
  
      if freeze_at >= 1:
          for p in stem.parameters():
              p.requires_grad = False
  
      out_features = config.MODEL.RESNETS.OUT_FEATURES
      depth = config.MODEL.RESNETS.DEPTH
      num_groups = config.MODEL.RESNETS.NUM_GROUPS
      width_per_group = config.MODEL.RESNETS.WIDTH_PER_GROUP
      bottleneck_channels = num_groups * width_per_group
      in_channels = config.MODEL.RESNETS.STEM_OUT_CHANNELS
      out_channels = config.MODEL.RESNETS.RES2_OUT_CHANNELS
      stride_in_1x1 = config.MODEL.RESNETS.STRIDE_IN_1X1
      res5_dilation = config.MODEL.RESNETS.RES5_DILATION
      assert res5_dilation in {
          1,
          2,
      }, f"res5_dilation cannot be {res5_dilation}."
  
      num_blocks_per_stage = {
          50: [3, 4, 6, 3],
          101: [3, 4, 23, 3],
          152: [3, 8, 36, 3],
      }[depth]
  
      stages = []
      out_stage_idx = [
          {"res2": 2, "res3": 3, "res4": 4, "res5": 5}[f]
          for f in out_features
      ]
      max_stage_idx = max(out_stage_idx)
      for idx, stage_idx in enumerate(range(2, max_stage_idx + 1)):
          dilation = res5_dilation if stage_idx == 5 else 1
          first_stride = (
              1 if idx == 0 or (stage_idx == 5 and dilation == 2) else 2
          )
          stage_kargs = {
              "num_blocks": num_blocks_per_stage[idx],
              "stride_per_block": [first_stride]
              + [1] * (num_blocks_per_stage[idx] - 1),
              "in_channels": in_channels,
              "bottleneck_channels": bottleneck_channels,
              "out_channels": out_channels,
              "num_groups": num_groups,
              "norm": norm,
              "stride_in_1x1": stride_in_1x1,
              "dilation": dilation,
          }
  
          stage_kargs["block_class"] = BottleneckBlock
          blocks = ResNet.make_stage(**stage_kargs)
          in_channels = out_channels
          out_channels *= 2
          bottleneck_channels *= 2
  
          stages.append(blocks)
  
      return ResNet(
          stem, stages, out_features=out_features, freeze_at=-1
      )
  
file_path: mmf/mmf/models/frcnn.py
imports: from typing import List
  import omegaconf
  import torch
  from torch import nn
  from torch.nn import functional
label_desc: Use image node_id 1 for calling a global function with example usage: build_backbone(config) and returns: ResNet