code: def load_state_dict_into_model(
      model: nn.Module,
      state_dict: torch.Tensor,
      missing_keys: List,
      strict: bool = False,
      load_sub_module: bool = True,
  ):
      r"""Copies parameters and buffers from :attr:`state_dict` into
      this module and its descendants.
  
      Args:
          state_dict (dict): a dict containing parameters and
              persistent buffers.
      """
      if not isinstance(state_dict, Mapping):
          raise TypeError(
              "Expected state_dict to be dict-like, got {}.".format(
                  type(state_dict)
              )
          )
  
      unexpected_keys: List[str] = []
      sub_missing_keys: List[str] = []
      error_msgs: List[str] = []
  
      # copy state_dict so _load_from_state_dict can modify it
      metadata = getattr(state_dict, "_metadata", None)
      state_dict = OrderedDict(state_dict)
      if metadata is not None:
          state_dict._metadata = metadata
  
      def load(
          module: nn.Module,
          state_dict,
          prefix="",
          load_sub_module: bool = True,
      ):
          local_metadata = (
              {} if metadata is None else metadata.get(prefix[:-1], {})
          )
          args = (
              state_dict,
              prefix,
              local_metadata,
              True,
              sub_missing_keys,
              [],
              error_msgs,
          )
          # Parameters of module and children will start with prefix. We can exit early if there are none in this
          # state_dict
          if (
              len([key for key in state_dict if key.startswith(prefix)])
              > 0
          ):
              module._load_from_state_dict(*args)
          if load_sub_module:
              for name, child in module._modules.items():
                  if child is not None:
                      load(child, state_dict, prefix + name + ".")
  
      load(model, state_dict, "", load_sub_module)
      del load
  
      missing_keys = missing_keys.append(sub_missing_keys)
  
      if strict:
          if len(unexpected_keys) > 0:
              error_msgs = (
                  "Unexpected key(s) in state_dict: {}. ".format(
                      ", ".join(
                          '"{}"'.format(k) for k in unexpected_keys
                      )
                  )
              )
              raise RuntimeError(
                  "Error(s) in loading state_dict for {}:\n\t{}".format(
                      model.__class__.__name__, "\n\t".join(error_msgs)
                  )
              )
  
imports: import os
  import re
  from collections import abc
  from collections import defaultdict
  from itertools import chain
  from pathlib import Path
  from typing import Iterator, List, Mapping, Optional, OrderedDict, Tuple
  import torch
  import torch.nn
  from packaging.version import Version
  from torch.optim import Optimizer
  from torch.utils._pytree import tree_map
  from colossalai.tensor.d_tensor import is_customized_distributed_tensor, is_distributed_tensor, to_global, to_global_for_customized_distributed_tensor
label_desc: Use image node_id 19 for calling a global function with example usage: load_state_dict_into_model(model, state_dict, missing_keys, strict, load_sub_module) without return types