class_docstr: Helper class for renaming string contents.
docstr: Create a renamer object.
  
  Args:
      rules: the replacement mapping.
      chain: optionally, another renamer to call after this one completes.
docstr_tok: ["Create","a","renamer","object",".","Args",":","rules",":","the","replacement","mapping",".","chain",":","optionally",",","another","renamer","to","call","after","this","one","completes","."]
code: def __init__(
      self,
      rules: Union[
          Dict[str, str],
          Sequence[Tuple[Pattern[str], str]],
          Callable[[str], str],
      ],
      chain: Optional["Renamer"] = None,
  ):
      """Create a renamer object.
  
      Args:
          rules: the replacement mapping.
          chain: optionally, another renamer to call after this one completes.
      """
      self.chain = chain
      if callable(rules):
          self.subfn = rules
      elif isinstance(rules, dict):
          regex = re.compile(
              "(%s)" % "|".join(map(re.escape, rules.keys()))
          )
          self.subfn = functools.partial(
              regex.sub, lambda m: rules[m.group(0)]
          )
      else:
  
          def sequence_rename(x):
              for regex, repl in rules:
                  x = regex.sub(repl, x)
              return x
  
          self.subfn = sequence_rename
  
imports: import contextlib
  import functools
  import inspect
  import itertools
  import re
  from numbers import Number
  from typing import Callable, List, Union, Tuple, Iterable, Dict, Pattern, Optional, Sequence
  import jax
  import jax.numpy
  import numpy
  from objax.constants import ConvPadding, Interpolate
  from objax.typing import ConvPaddingInt
label_desc: Use image node_id 1 to create a new Renamer object  with example: obj = Renamer(rules, chain)