code: def testDuplicate(self):
      myreg = registry.Registry("testbar")
      myreg.register(bar, "Bar")
      with self.assertRaisesRegex(
          KeyError,
          r"Registering two testbar with name \'Bar\'! "
          r"\(Previous registration was in [^ ]+ .*.py:[0-9]+\)",
      ):
          myreg.register(bar, "Bar")
  
file_path: tensorflow-upstream/tensorflow/python/framework/registry_test.py
imports: from absl.testing import parameterized
  from tensorflow.python.framework import registry
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling the RegistryTest obj's underlying member method code with example usage: obj.testDuplicate() without return types