code: def rename_get_variable(mapping):
      """
      Args:
          mapping(dict): an old -> new mapping for variable basename. e.g. {'kernel': 'W'}
  
      Returns:
          A context where the variables are renamed.
      """
  
      def custom_getter(getter, name, *args, **kwargs):
          splits = name.split("/")
          basename = splits[-1]
          if basename in mapping:
              basename = mapping[basename]
              splits[-1] = basename
              name = "/".join(splits)
          return getter(name, *args, **kwargs)
  
      return custom_getter_scope(custom_getter)
  
file_path: tensorpack/tensorpack/models/tflayer.py
imports: import functools
  import six
  import tensorflow
  from ..tfutils.common import get_tf_version_tuple
  from ..tfutils.varreplace import custom_getter_scope
  from ..utils.argtools import get_data_format
label_desc: Use image node_id 3 for calling a global function with example usage: rename_get_variable(mapping) and returns: custom_getter_scope, getter