class_docstr: ResNet backbone with frozen BatchNorm.
  
  Args:
      name (`str`):
          Backbone name.
      train_backbone (`bool`):
          The flag to control train mode for backbone.
      return_interm_layers (`bool`):
          The flag to return intermediate layers.
      dilation (`bool`):
          The flag to use dilated model.
class_docstr_tok: ["ResNet","backbone","with","frozen","BatchNorm",".","Args",":","name","(","`","str","`",")",":","Backbone","name",".","train_backbone","(","`","bool","`",")",":","The","flag","to","control","train","mode","for","backbone",".","return_interm_layers","(","`","bool","`",")",":","The","flag","to","return","intermediate","layers",".","dilation","(","`","bool","`",")",":","The","flag","to","use","dilated","model","."]
code: def __init__(
      self,
      name: str,
      train_backbone: bool,
      return_interm_layers: bool,
      dilation: bool,
  ):
      if "resnet" in name:
          backbone = getattr(torchvision.models, name)(
              replace_stride_with_dilation=[False, False, dilation],
              pretrained=is_main_process(),
          )
          num_channels = (
              512 if name in ("resnet18", "resnet34") else 2048
          )
      else:
          # TODO only resnet is supported
          assert False, f"backbone {name} is not supported now"
      super().__init__(
          backbone,
          train_backbone,
          name,
          num_channels,
          return_interm_layers,
      )
  
file_path: towhee/towhee/models/coformer/backbone.py
imports: import torch
  import torch.nn.functional
  import torchvision
  from torch import nn
  from torchvision.models._utils import IntermediateLayerGetter
  from typing import Dict, List
  from towhee.models.coformer.utils import NestedTensor, is_main_process
  from towhee.models.layers.position_encoding import build_position_encoding
label_desc: Use image node_id 1 to create a new Backbone object from inherited base classes: BackboneBase with example: obj = Backbone(name, train_backbone, return_interm_layers, dilation)