code: def _checkpoint_filter_fn(state_dict, model):
      """Remap original checkpoints -> timm"""
      if "patch_embed.proj.weight" in state_dict:
          return (
              state_dict  # non-original checkpoint, no remapping needed
          )
  
      out_dict = {}
      import re
  
      for k, v in state_dict.items():
          if k.startswith("patch_embed"):
              k = k.replace("patch_embed1", "patch_embed")
              k = k.replace("patch_embed2", "stages.1.downsample")
              k = k.replace("patch_embed3", "stages.2.downsample")
              k = k.replace("patch_embed4", "stages.3.downsample")
          k = k.replace("dwconv.dwconv", "dwconv")
          k = re.sub(
              r"block(\d+).(\d+)",
              lambda x: f"stages.{int(x.group(1)) - 1}.blocks.{x.group(2)}",
              k,
          )
          k = re.sub(
              r"^norm(\d+)",
              lambda x: f"stages.{int(x.group(1)) - 1}.norm",
              k,
          )
          out_dict[k] = v
      return out_dict
  
imports: import math
  from typing import Tuple, List, Callable, Union
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import DropPath, to_2tuple, to_ntuple, trunc_normal_, LayerNorm, use_fused_attn
  from ._builder import build_model_with_cfg
  from ._registry import register_model, generate_default_cfgs
label_desc: Use image node_id 1 for calling a global function with example usage: _checkpoint_filter_fn(state_dict, model) and returns: out_dict, state_dict