def is_inverse_pair(node_op, prev_op, inv_pair):
 node_is_op0 = isinstance(node_op, inv_pair[0])
 node_is_op1 = isinstance(node_op, inv_pair[1])
 prev_is_op0 = isinstance(prev_op, inv_pair[0])
 prev_is_op1 = isinstance(prev_op, inv_pair[1])
 return ((node_is_op0 and prev_is_op1) or (node_is_op1 and prev_is_op0))

def is_inverse_pair ( node_op , prev_op , inv_pair ) : node_is_op0 = isinstance ( node_op , inv_pair [ 0 ] ) node_is_op1 = isinstance ( node_op , inv_pair [ 1 ] ) prev_is_op0 = isinstance ( prev_op , inv_pair [ 0 ] ) prev_is_op1 = isinstance ( prev_op , inv_pair [ 1 ] ) return ( ( node_is_op0 and prev_is_op1 ) or ( node_is_op1 and prev_is_op0 ) )
given two consecutive operations .