code: def translate_roberta_state_dict(state_dict):
      """Translate the public RoBERTa weights to ones which match SentenceEncoder."""
  
      new_state = rename_component_from_root(
          state_dict, "decoder.sentence_encoder", "transformer"
      )
      new_state = rename_component_from_root(
          new_state, "encoder.sentence_encoder", "transformer"
      )
  
      new_state = rename_state_keys(
          new_state, "embed_tokens", "token_embedding"
      )
      # TODO: segment_embeddings?
      new_state = rename_state_keys(
          new_state, "embed_positions", "positional_embedding.embedding"
      )
      new_state = rename_state_keys(
          new_state, "emb_layer_norm", "embedding_layer_norm"
      )
      new_state = rename_state_keys(new_state, "self_attn", "attention")
      # Linformer special handling
      if check_state_keys(new_state, "compress_k"):
          new_state = remove_state_keys(new_state, "compress_layer")
      else:
          new_state = merge_input_projection(new_state)
  
      new_state = rename_state_keys(
          new_state, "_proj.(.*)", r"put_projection.\1"
      )
      new_state = rename_state_keys(
          new_state, "fc1", "residual_mlp.mlp.0"
      )
      new_state = rename_state_keys(
          new_state, "fc2", "residual_mlp.mlp.3"
      )
  
      new_state = remove_state_keys(new_state, "^sentence_")
      new_state = remove_state_keys(new_state, "_classification_head.")
      new_state = remove_state_keys(new_state, r"^decoder\.lm_head")
      new_state = remove_state_keys(new_state, r"^encoder\.lm_head")
      new_state = remove_state_keys(new_state, r"segment_embedding")
  
      return new_state
  
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 6 for calling a global function with example usage: translate_roberta_state_dict(state_dict) and returns: new_state