code: def test_resnet_fpn_backbone_frozen_layers(
      self, train_layers, exp_froz_params
  ):
      # we know how many initial layers and parameters of the network should
      # be frozen for each trainable_backbone_layers parameter value
      # i.e. all 53 params are frozen if trainable_backbone_layers=0
      # ad first 24 params are frozen if trainable_backbone_layers=2
      model = backbone_utils.resnet_fpn_backbone(
          "resnet50", weights=None, trainable_layers=train_layers
      )
      # boolean list that is true if the param at that index is frozen
      is_frozen = [
          not parameter.requires_grad
          for _, parameter in model.named_parameters()
      ]
      # check that expected initial number of layers are frozen
      assert all(is_frozen[:exp_froz_params])
  
file_path: vision/test/test_models_detection_utils.py
imports: import copy
  import pytest
  import torch
  from common_utils import assert_equal
  from torchvision.models.detection import _utils, backbone_utils
  from torchvision.models.detection.transform import GeneralizedRCNNTransform
label_desc: Use image node_id 3 for calling the TestModelsDetectionUtils obj's underlying member method code with example usage: obj.test_resnet_fpn_backbone_frozen_layers(train_layers, exp_froz_params) without return types