code: def _are_inverses(op1, op2):
      """Checks if two operators are inverses of each other
  
      Args:
          op1 (~.Operator)
          op2 (~.Operator)
  
      Returns:
          Bool
      """
      # op1 is self-inverse and the next gate is also op1
      if op1 in self_inverses and op1.name == op2.name:
          return True
  
      # op1 is an `Adjoint` class and its base is equal to op2
      if isinstance(op1, Adjoint) and _ops_equal(op1.base, op2):
          return True
  
      # op2 is an `Adjoint` class and its base is equal to op1
      if isinstance(op2, Adjoint) and _ops_equal(op2.base, op1):
          return True
  
      return False
  
file_path: pennylane/pennylane/transforms/optimization/cancel_inverses.py
imports: from typing import Sequence, Callable
  from pennylane.ops.op_math import Adjoint
  from pennylane.wires import Wires
  from pennylane.tape import QuantumTape
  from pennylane.transforms import transform
  from pennylane.ops.qubit.attributes import self_inverses, symmetric_over_all_wires, symmetric_over_control_wires
  from .optimization_utils import find_next_gate
label_desc: Use image node_id 2 for calling a global function with example usage: _are_inverses(op1, op2) and returns: False, True, True, True