code: def _rename_weights_for_resnet(weights, stage_names):
      original_keys = sorted(weights.keys())
      layer_keys = sorted(weights.keys())
  
      # for X-101, rename output to fc1000 to avoid conflicts afterwards
      layer_keys = [
          k if k != "pred_b" else "fc1000_b" for k in layer_keys
      ]
      layer_keys = [
          k if k != "pred_w" else "fc1000_w" for k in layer_keys
      ]
  
      # performs basic renaming: _ -> . , etc
      layer_keys = _rename_basic_resnet_weights(layer_keys)
      key_map = {k: v for k, v in zip(original_keys, layer_keys)}
  
      logger.info("Remapping C2 weights")
      max_c2_key_size = max(
          len(k) for k in original_keys if "_momentum" not in k
      )
  
      new_weights = OrderedDict()
      for k in original_keys:
          v = weights[k]
          if "_momentum" in k:
              continue
          if "pred" in k:
              continue
          if k == "lr":
              continue
          if k == "model_iter":
              continue
          w = torch.from_numpy(v)
          logger.info(
              "C2 name: {: <{}} mapped name: {}".format(
                  k, max_c2_key_size, key_map[k]
              )
          )
          new_weights[key_map[k]] = w
      logger.info("Number of blobs: {}".format(len(new_weights)))
      return new_weights
  
file_path: vissl/extra_scripts/convert_caffe2_to_torchvision_resnet.py
imports: import argparse
  import logging
  import pickle
  import re
  import sys
  from collections import OrderedDict
  import torch
  from iopath.common.file_io import g_pathmgr
label_desc: Use image node_id 3 for calling a global function with example usage: _rename_weights_for_resnet(weights, stage_names) and returns: new_weights