class_docstr: Base class from which all rewriters should inherit.
class_docstr_tok: ["Base","class","from","which","all","rewriters","should","inherit","."]
docstr: Invoke all validations and perform the rewrite.
  
  Args:
    original_model: A `base_rewriter.ModelDescription` object describing the
      original model.
    rewritten_model: A `base_rewriter.ModelDescription` object describing the
      location and type of the rewritten model.
  
  Raises:
    ValueError: if the model was not successfully rewritten.
docstr_tok: ["Invoke","all","validations","and","perform","the","rewrite",".","Args",":","original_model",":","A","`","base_rewriter.ModelDescription","`","object","describing","the","original","model",".","rewritten_model",":","A","`","base_rewriter.ModelDescription","`","object","describing","the","location","and","type","of","the","rewritten","model",".","Raises",":","ValueError",":","if","the","model","was","not","successfully","rewritten","."]
code: def perform_rewrite(
      self,
      original_model: ModelDescription,
      rewritten_model: ModelDescription,
  ):
      """Invoke all validations and perform the rewrite.
  
      Args:
        original_model: A `base_rewriter.ModelDescription` object describing the
          original model.
        rewritten_model: A `base_rewriter.ModelDescription` object describing the
          location and type of the rewritten model.
  
      Raises:
        ValueError: if the model was not successfully rewritten.
      """
      try:
          self._pre_rewrite_validate(original_model)
      except ValueError as v:
          raise ValueError(
              "{} failed to perform pre-rewrite validation. Original "
              "model: {}. Error: {}".format(
                  self.name, str(original_model), str(v)
              )
          )
  
      try:
          self._rewrite(original_model, rewritten_model)
      except ValueError as v:
          raise ValueError(
              "{} failed to rewrite model. Original model: {}. Error {}".format(
                  self.name, str(original_model), str(v)
              )
          )
  
      try:
          self._post_rewrite_validate(rewritten_model)
      except ValueError as v:
          raise ValueError(
              "{} failed to validate rewritten model. Rewritten model: {}. Error {}".format(
                  self.name, str(rewritten_model), str(v)
              )
          )
  
file_path: tfx/tfx/components/trainer/rewriting/rewriter.py
imports: import abc
  import collections
  import enum
label_desc: Use image node_id 5 for calling the BaseRewriter obj's underlying member method code with example usage: obj.perform_rewrite(original_model, rewritten_model) without return types