code: def test_renamer(self):
      r = objax.util.Renamer({"aa": "x", "bb": "y"})
      self.assertEqual(r("baab"), "bxb")
      self.assertEqual(r("baaab"), "bxab")
      self.assertEqual(r("baaaab"), "bxxb")
      self.assertEqual(r("abba"), "aya")
      self.assertEqual(r("acca"), "acca")
  
      def my_rename(x):
          return x.replace("aa", "x").replace("bb", "y")
  
      r = objax.util.Renamer(my_rename)
      self.assertEqual(r("baab"), "bxb")
      self.assertEqual(r("baaab"), "bxab")
      self.assertEqual(r("baaaab"), "bxxb")
      self.assertEqual(r("abba"), "aya")
      self.assertEqual(r("acca"), "acca")
  
      r = objax.util.Renamer(
          [(re.compile("a{2}"), "x"), (re.compile("bb"), "y")]
      )
      self.assertEqual(r("baab"), "bxb")
      self.assertEqual(r("baaab"), "bxab")
      self.assertEqual(r("baaaab"), "bxxb")
      self.assertEqual(r("abba"), "aya")
      self.assertEqual(r("acca"), "acca")
  
      r = objax.util.Renamer(
          [(re.compile("(a)(a)"), "x"), (re.compile("bb"), "y")]
      )
      self.assertEqual(r("baab"), "bxb")
  
      r = objax.util.Renamer(
          [(re.compile("a{2}"), "x"), (re.compile("xa"), "y")]
      )
      self.assertEqual(r("baaab"), "byb")
  
      r = objax.util.Renamer(
          {"aa": "x"}, chain=objax.util.Renamer({"xa": "y"})
      )
      self.assertEqual(r("baaab"), "byb")
  
file_path: objax/tests/util.py
imports: import re
  import unittest
  import objax
label_desc: Use image node_id 2 for calling the TestUtil obj's underlying member method code with example usage: obj.test_renamer() and returns: x