code: def translate_encoder_from_stl_text(state_dict):
      regex = re.compile("^model.encoder(.*)$")
      translated = {}
      for k, v in state_dict.items():
          if regex.findall(k):
              new_key = regex.sub(r"encoder\1", k)
              translated[new_key] = v
      return translated
  
imports: import re
  from typing import List, Optional
  import torch
  from pytext.utils.usage import log_class_usage
  from pytorch.text.fb.nn.modules.transformer import Transformer
  from torch import nn
label_desc: Use image node_id 8 for calling a global function with example usage: translate_encoder_from_stl_text(state_dict) and returns: translated