code: def _load_state_dict(model: nn.Module, arch: str, progress: bool):
      """
      This function is used to load pretrained models.
      Adapted from PyTorch Hub 2D version: https://pytorch.org/vision/stable/models.html#id16.
  
      """
      model_urls = {
          "densenet121": "https://download.pytorch.org/models/densenet121-a639ec97.pth",
          "densenet169": "https://download.pytorch.org/models/densenet169-b2777c0a.pth",
          "densenet201": "https://download.pytorch.org/models/densenet201-c1103571.pth",
      }
      model_url = look_up_option(arch, model_urls, None)
      if model_url is None:
          raise ValueError(
              "only 'densenet121', 'densenet169' and 'densenet201' are supported to load pretrained weights."
          )
  
      pattern = re.compile(
          r"^(.*denselayer\d+)(\.(?:norm|relu|conv))\.((?:[12])\.(?:weight|bias|running_mean|running_var))$"
      )
  
      state_dict = load_state_dict_from_url(
          model_url, progress=progress
      )
      for key in list(state_dict.keys()):
          res = pattern.match(key)
          if res:
              new_key = (
                  res.group(1) + ".layers" + res.group(2) + res.group(3)
              )
              state_dict[new_key] = state_dict[key]
              del state_dict[key]
  
      model_dict = model.state_dict()
      state_dict = {
          k: v
          for k, v in state_dict.items()
          if (k in model_dict)
          and (model_dict[k].shape == state_dict[k].shape)
      }
      model_dict.update(state_dict)
      model.load_state_dict(model_dict)
  
imports: from __future__ import annotations
  import re
  from collections import OrderedDict
  from collections.abc import Callable, Sequence
  import torch
  import torch.nn
  from torch.hub import load_state_dict_from_url
  from monai.networks.layers.factories import Conv, Dropout, Pool
  from monai.networks.layers.utils import get_act_layer, get_norm_layer
  from monai.utils.module import look_up_option
label_desc: Use image node_id 1 for calling a global function with example usage: _load_state_dict(model, arch, progress) without return types