code: def freeze_model_layers(model, frozen_layers):
      """
      Freeze model layers with pattern in frozen_layers.
  
      Parameters
      ----------
      model
          The pytorch model.
      frozen_layers
          A list of substrings of frozen layers' names.
  
          e.g. if frozen_layers = ["backbone", "neck"],
              all layers including "backbone" or "neck" in the name will be frozen.
      """
  
      if not frozen_layers:
          return
  
      is_frozen_layer = lambda n: any(bb in n for bb in frozen_layers)
  
      for n, p in model.named_parameters():
          if is_frozen_layer(n):
              p.requires_grad = False
  
imports: import logging
  import re
  import warnings
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch._dynamo
  import torch.nn.functional
  from torch import nn
  from torch.nn.modules.loss import _Loss
  from transformers import AutoConfig, AutoModel, AutoTokenizer, BertTokenizer, CLIPTokenizer, ElectraTokenizer
  from transformers.models.mask2former.modeling_mask2former import Mask2FormerLoss
  from ..constants import AUTOMM, CLASS_LOGITS, COLUMN_FEATURES, FEATURES, LOGITS, MASKS, OCR, PEFT_ADDITIVE_STRATEGIES, REGRESSION, SEMANTIC_MASK, SEMANTIC_SEGMENTATION
  from .adaptation_layers import IA3Linear, IA3LoRALinear, LoRALinear
label_desc: Use image node_id 20 for calling a global function with example usage: freeze_model_layers(model, frozen_layers) without return types