code: def checkpoint_filter_fn(state_dict, model):
      if "body.conv1.conv.weight" in state_dict:
          return state_dict
  
      import re
  
      state_dict = state_dict.get("model", state_dict)
      state_dict = state_dict.get("state_dict", state_dict)
      out_dict = {}
      for k, v in state_dict.items():
          k = re.sub(
              r"conv(\d+)\.0.0",
              lambda x: f"conv{int(x.group(1))}.conv",
              k,
          )
          k = re.sub(
              r"conv(\d+)\.0.1",
              lambda x: f"conv{int(x.group(1))}.bn",
              k,
          )
          k = re.sub(
              r"conv(\d+)\.0",
              lambda x: f"conv{int(x.group(1))}.conv",
              k,
          )
          k = re.sub(
              r"conv(\d+)\.1", lambda x: f"conv{int(x.group(1))}.bn", k
          )
          k = re.sub(
              r"downsample\.(\d+)\.0",
              lambda x: f"downsample.{int(x.group(1))}.conv",
              k,
          )
          k = re.sub(
              r"downsample\.(\d+)\.1",
              lambda x: f"downsample.{int(x.group(1))}.bn",
              k,
          )
          if k.endswith("bn.weight"):
              # convert weight from inplace_abn to batchnorm
              v = v.abs().add(1e-5)
          out_dict[k] = v
      return out_dict
  
imports: from collections import OrderedDict
  from functools import partial
  import torch
  import torch.nn
  from timm.layers import SpaceToDepth, BlurPool2d, ClassifierHead, SEModule, ConvNormActAa, ConvNormAct, DropPath
  from ._builder import build_model_with_cfg
  from ._manipulate import checkpoint_seq
  from ._registry import register_model, generate_default_cfgs, register_model_deprecations
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