code: def checkpoint_filter_fn(state_dict, model):
      """Remap MSFT checkpoints -> timm"""
      if "head.fc.weight" in state_dict:
          return state_dict  # non-MSFT checkpoint
  
      if "state_dict" in state_dict:
          state_dict = state_dict["state_dict"]
  
      import re
  
      out_dict = {}
      for k, v in state_dict.items():
          k = re.sub(
              r"patch_embeds.([0-9]+)", r"stages.\1.downsample", k
          )
          k = re.sub(r"main_blocks.([0-9]+)", r"stages.\1.blocks", k)
          k = k.replace("downsample.proj", "downsample.conv")
          k = k.replace("stages.0.downsample", "stem")
          k = k.replace("head.", "head.fc.")
          k = k.replace("norms.", "head.norm.")
          k = k.replace("cpe.0", "cpe1")
          k = k.replace("cpe.1", "cpe2")
          out_dict[k] = v
      return out_dict
  
imports: from functools import partial
  from typing import Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import DropPath, to_2tuple, trunc_normal_, Mlp, LayerNorm2d, get_norm_layer, use_fused_attn
  from timm.layers import NormMlpClassifierHead, ClassifierHead
  from ._builder import build_model_with_cfg
  from ._features_fx import register_notrace_function
  from ._manipulate import checkpoint_seq
  from ._registry import generate_default_cfgs, register_model
label_desc: Use image node_id 3 for calling a global function with example usage: checkpoint_filter_fn(state_dict, model) and returns: out_dict, state_dict