code: def adapt_model_from_string(parent_module, model_string):
      separator = "***"
      state_dict = {}
      lst_shape = model_string.split(separator)
      for k in lst_shape:
          k = k.split(":")
          key = k[0]
          shape = k[1][1:-1].split(",")
          if shape[0] != "":
              state_dict[key] = [int(i) for i in shape]
  
      new_module = deepcopy(parent_module)
      for n, m in parent_module.named_modules():
          old_module = extract_layer(parent_module, n)
          if isinstance(old_module, nn.Conv2d) or isinstance(
              old_module, Conv2dSame
          ):
              if isinstance(old_module, Conv2dSame):
                  conv = Conv2dSame
              else:
                  conv = nn.Conv2d
              s = state_dict[n + ".weight"]
              in_channels = s[1]
              out_channels = s[0]
              g = 1
              if old_module.groups > 1:
                  in_channels = out_channels
                  g = in_channels
              new_conv = conv(
                  in_channels=in_channels,
                  out_channels=out_channels,
                  kernel_size=old_module.kernel_size,
                  bias=old_module.bias is not None,
                  padding=old_module.padding,
                  dilation=old_module.dilation,
                  groups=g,
                  stride=old_module.stride,
              )
              set_layer(new_module, n, new_conv)
          if isinstance(old_module, nn.BatchNorm2d):
              new_bn = nn.BatchNorm2d(
                  num_features=state_dict[n + ".weight"][0],
                  eps=old_module.eps,
                  momentum=old_module.momentum,
                  affine=old_module.affine,
                  track_running_stats=True,
              )
              set_layer(new_module, n, new_bn)
          if isinstance(old_module, nn.Linear):
              # FIXME extra checks to ensure this is actually the FC classifier layer and not a diff Linear layer?
              num_features = state_dict[n + ".weight"][1]
              new_fc = Linear(
                  in_features=num_features,
                  out_features=old_module.out_features,
                  bias=old_module.bias is not None,
              )
              set_layer(new_module, n, new_fc)
              if hasattr(new_module, "num_features"):
                  new_module.num_features = num_features
      new_module.eval()
      parent_module.eval()
  
      return new_module
  
imports: import logging
  import os
  import math
  from collections import OrderedDict
  from copy import deepcopy
  from typing import Any, Callable, Optional, Tuple
  import torch
  import torch.nn
  from torch.hub import load_state_dict_from_url
  from timm.models.features import FeatureListNet, FeatureDictNet, FeatureHookNet
  from timm.models.fx_features import FeatureGraphNet
  from timm.models.hub import has_hf_hub, download_cached_file, load_state_dict_from_hf
  from timm.models.layers import Conv2dSame, Linear
  from timm.models.vision_transformer import VisionTransformer, resize_pos_embed
  import tutel.impls.moe_layer
label_desc: Use image node_id 10 for calling a global function with example usage: adapt_model_from_string(parent_module, model_string) and returns: new_module