code: def create_model(num_classes):
      import torchvision
      from torchvision.models.feature_extraction import (
          create_feature_extractor,
      )
  
      # --- mobilenet_v3_large fpn backbone --- #
      backbone = torchvision.models.mobilenet_v3_large(pretrained=True)
      # print(backbone)
      return_layers = {
          "features.6": "0",  # stride 8
          "features.12": "1",  # stride 16
          "features.16": "2",
      }  # stride 32
      # 提供给fpn的每个特征层channel
      in_channels_list = [40, 112, 960]
      new_backbone = create_feature_extractor(backbone, return_layers)
      # img = torch.randn(1, 3, 224, 224)
      # outputs = new_backbone(img)
      # [print(f"{k} shape: {v.shape}") for k, v in outputs.items()]
  
      # --- efficientnet_b0 fpn backbone --- #
      # backbone = torchvision.models.efficientnet_b0(pretrained=True)
      # # print(backbone)
      # return_layers = {"features.3": "0",  # stride 8
      #                  "features.4": "1",  # stride 16
      #                  "features.8": "2"}  # stride 32
      # # 提供给fpn的每个特征层channel
      # in_channels_list = [40, 80, 1280]
      # new_backbone = create_feature_extractor(backbone, return_layers)
      # # img = torch.randn(1, 3, 224, 224)
      # # outputs = new_backbone(img)
      # # [print(f"{k} shape: {v.shape}") for k, v in outputs.items()]
  
      backbone_with_fpn = BackboneWithFPN(
          new_backbone,
          return_layers=return_layers,
          in_channels_list=in_channels_list,
          out_channels=256,
          extra_blocks=LastLevelMaxPool(),
          re_getter=False,
      )
  
      anchor_sizes = ((64,), (128,), (256,), (512,))
      aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes)
      anchor_generator = AnchorsGenerator(
          sizes=anchor_sizes, aspect_ratios=aspect_ratios
      )
  
      roi_pooler = torchvision.ops.MultiScaleRoIAlign(
          featmap_names=["0", "1", "2"],  # 在哪些特征层上进行RoIAlign pooling
          output_size=[7, 7],  # RoIAlign pooling输出特征矩阵尺寸
          sampling_ratio=2,
      )  # 采样率
  
      model = FasterRCNN(
          backbone=backbone_with_fpn,
          num_classes=num_classes,
          rpn_anchor_generator=anchor_generator,
          box_roi_pool=roi_pooler,
      )
  
      return model
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/train_coco_dataset/change_backbone_with_fpn.py
imports: import os
  import datetime
  import torch
  import transforms
  from network_files import FasterRCNN, AnchorsGenerator
  from my_dataset import CocoDetection
  from train_utils import GroupedBatchSampler, create_aspect_ratio_groups
  from train_utils import train_eval_utils
  from backbone import BackboneWithFPN, LastLevelMaxPool
label_desc: Use image node_id 1 for calling a global function with example usage: create_model(num_classes) and returns: model