code: def testAddVariableOverwrite(self):
      root = base.Trackable()
      a = root._add_variable_with_custom_getter(
          name="v", shape=[], getter=variable_scope.get_variable
      )
      self.assertEqual([root, a], util.list_objects(root))
      with ops.Graph().as_default():
          b = root._add_variable_with_custom_getter(
              name="v",
              shape=[],
              overwrite=True,
              getter=variable_scope.get_variable,
          )
          self.assertEqual([root, b], util.list_objects(root))
      with ops.Graph().as_default():
          with self.assertRaisesRegex(
              ValueError, "already declared as a dependency"
          ):
              root._add_variable_with_custom_getter(
                  name="v",
                  shape=[],
                  overwrite=False,
                  getter=variable_scope.get_variable,
              )
  
file_path: tensorflow-upstream/tensorflow/python/trackable/base_test.py
imports: import os
  from tensorflow.python.checkpoint import checkpoint
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.platform import test
  from tensorflow.python.trackable import base
label_desc: Use image node_id 2 for calling the InterfaceTests obj's underlying member method code with example usage: obj.testAddVariableOverwrite() without return types