code: def _rename_weights_to_d2(weights, weights_type):
      original_keys = sorted(weights.keys())
      layer_keys = sorted(weights.keys())
  
      # basic layer mapping to detectron names
      layer_keys = convert_to_detectron2_names(layer_keys)
      key_map = {k: v for k, v in zip(original_keys, layer_keys)}
  
      logger.info("Remapping weights....")
      new_weights = OrderedDict()
      for k in original_keys:
          if any(x in k for x in _SKIP_LAYERS):
              continue
          if weights_type == "torch":
              v = np.array(weights[k].detach().cpu())
          else:
              v = np.array(weights[k])
          w = torch.from_numpy(v)
          logger.info(
              f"original name: {k} \t\t mapped name: {key_map[k]}"
          )
          new_weights[key_map[k]] = w
      logger.info("Number of params: {}".format(len(new_weights)))
      return new_weights
  
file_path: vissl/extra_scripts/convert_vissl_to_detectron2.py
imports: import argparse
  import logging
  import re
  import sys
  from collections import OrderedDict
  import numpy
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: _rename_weights_to_d2(weights, weights_type) and returns: new_weights