code: def rename_checkpoint_to_partial(source, target, transform):
      vars = tf.contrib.framework.list_variables(source)
      var_names = [v.split("/") for v, s in vars]
      transform_pairs = []
      for s_name, t_name in transform:
          print(vars, s_name, t_name)
          if s_name[-1] == "/" and t_name[-1] == "/":  # scope
              s_names = s_name.split("/")[:-1]
              t_names = t_name.split("/")[:-1]
              transform_pairs += [
                  ("/".join(v), "/".join(t_names + v[len(s_names) :]))
                  for v in var_names
                  if v[: len(s_names)] == s_names
              ]
          elif s_name[-1] != "/" and t_name[-1] != "/":  # variable
              if s_name in [v for v, s in vars]:
                  transform_pairs.append((s_name, t_name))
          else:
              raise ValueError(
                  "Cannot rename a variable to a scope or vice versa: %s->%s"
                  % (s_name, t_name)
              )
      print(transform_pairs)
      g = tf.Graph()
      with g.as_default():
          with tf.Session() as sess:
              for s_name, t_name in transform_pairs:
                  var = tf.contrib.framework.load_variable(
                      source, s_name
                  )
                  var = tf.Variable(var, name=t_name)
              saver = tf.train.Saver()
              sess.run(tf.global_variables_initializer())
              saver.save(sess, target)
  
label_desc: Use image node_id 1 for calling a global function with example usage: rename_checkpoint_to_partial(source, target, transform) without return types