class_docstr: Class to run the substitution algorithm from the list of maximal matches.
class_docstr_tok: ["Class","to","run","the","substitution","algorithm","from","the","list","of","maximal","matches","."]
docstr: The template circuit realizes the identity operator, then given the list of matches in the template,
  it returns the inverse part of the template that will be replaced.
  Args:
      template_list (list): list of all gates in the template.
      template_sublist (list): list of the gates matched in the circuit.
      template_complement  (list): list of gates not matched in the template.
  Returns:
      list(int): the template inverse part that will substitute the circuit match.
code: def _template_inverse(
      self, template_list, template_sublist, template_complement
  ):
      """The template circuit realizes the identity operator, then given the list of matches in the template,
      it returns the inverse part of the template that will be replaced.
      Args:
          template_list (list): list of all gates in the template.
          template_sublist (list): list of the gates matched in the circuit.
          template_complement  (list): list of gates not matched in the template.
      Returns:
          list(int): the template inverse part that will substitute the circuit match.
      """
      inverse = template_complement
      left = []
      right = []
  
      pred = set()
      for index in template_sublist:
          pred = pred | set(
              self.template_dag.get_node(index).predecessors
          )
      pred = list(pred - set(template_sublist))
  
      succ = set()
      for index in template_sublist:
          succ = succ | set(
              self.template_dag.get_node(index).successors
          )
      succ = list(succ - set(template_sublist))
  
      comm = list(set(template_list) - set(pred) - set(succ))
  
      for elem in inverse:
          if elem in pred:
              left.append(elem)
          elif elem in succ:
              right.append(elem)
          elif elem in comm:
              right.append(elem)
  
      left.sort()
      right.sort()
  
      left.reverse()
      right.reverse()
  
      total = left + right
      return total
  
imports: import copy
  import itertools
  from collections import OrderedDict
  from typing import Sequence, Callable
  import numpy
  import pennylane
  from pennylane.transforms import transform
  from pennylane import adjoint
  from pennylane.ops.qubit.attributes import symmetric_over_all_wires
  from pennylane.tape import QuantumTape, QuantumScript
  from pennylane.transforms.commutation_dag import commutation_dag
  from pennylane.wires import Wires
label_desc: Use image node_id 5 for calling the TemplateSubstitution obj's underlying member method code with example usage: obj._template_inverse(template_list, template_sublist, template_complement) and returns: total