code: def get_submodel_from_state_dict(state_dict, prefix):
      # get only submodel specified with prefix 'prefix' from the state_dict
      new_state_dict = OrderedDict()
      for key, value in state_dict.items():
          if key.startswith(prefix):
              key = key[len(prefix) + 1 :]  # +1 for '.'
              new_state_dict[key] = value
      return new_state_dict
  
imports: import os
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from tqdm import tqdm
  from collections import OrderedDict
  from pytorch_transformers.modeling_bert import BertPreTrainedModel, BertConfig, BertModel
  from pytorch_transformers.tokenization_bert import BertTokenizer
  from elq.common.ranker_base import BertEncoder, get_model_obj
  from blink.common.optimizer import get_bert_optimizer
  from elq.biencoder.allennlp_span_utils import batched_span_select, batched_index_select
  from elq.biencoder.utils import batch_reshape_mask_left
label_desc: Use image node_id 2 for calling a global function with example usage: get_submodel_from_state_dict(state_dict, prefix) and returns: new_state_dict