class_docstr: Backbone base block.
  
  Args:
      backbone(`nn.Module`):
          Backbone model.
      train_backbone(`bool`):
          If backbone trained.
      name_backbone(`str`):
          Name of the backbone.
      num_channels(`int`):
          The number of the channels.
      return_interm_layers(`bool`):
          If the model returns intermediate layers.
class_docstr_tok: ["Backbone","base","block",".","Args",":","backbone","(","`","nn.Module","`",")",":","Backbone","model",".","train_backbone","(","`","bool","`",")",":","If","backbone","trained",".","name_backbone","(","`","str","`",")",":","Name","of","the","backbone",".","num_channels","(","`","int","`",")",":","The","number","of","the","channels",".","return_interm_layers","(","`","bool","`",")",":","If","the","model","returns","intermediate","layers","."]
code: def __init__(
      self,
      backbone: nn.Module,
      train_backbone: bool,
      name_backbone: str,
      num_channels: int,
      return_interm_layers: bool,
  ) -> None:
      super().__init__()
      if "resnet" in name_backbone:
          if not train_backbone:
              for _, parameter in backbone.named_parameters():
                  parameter.requires_grad_(False)
          if return_interm_layers:
              return_layers = {
                  "layer1": "0",
                  "layer2": "1",
                  "layer3": "2",
                  "layer4": "3",
              }
          else:
              return_layers = {"layer4": "0"}
      else:
          # only resnet50 is supported
          assert False, f"backbone {name_backbone} is not supported now"
      self.body = IntermediateLayerGetter(
          backbone, return_layers=return_layers
      )
      self.num_channels = num_channels
  
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 BackboneBase object from inherited base classes: nn with example: obj = BackboneBase(backbone, train_backbone, name_backbone, num_channels, return_interm_layers)