def _pairwise_broadcast(shape1, shape2):
 (shape1, shape2) = map(tuple, [shape1, shape2])
 while (len(shape1) < len(shape2)):
  shape1 = ((1,) + shape1)
 while (len(shape1) > len(shape2)):
  shape2 = ((1,) + shape2)
 return tuple((_broadcast_axis(a, b) for (a, b) in zip(shape1, shape2)))

def _pairwise_broadcast ( shape1 , shape2 ) : ( shape1 , shape2 ) = map ( tuple , [ shape1 , shape2 ] ) while ( len ( shape1 ) < len ( shape2 ) ) : shape1 = ( ( 1 , ) + shape1 ) while ( len ( shape1 ) > len ( shape2 ) ) : shape2 = ( ( 1 , ) + shape2 ) return tuple ( ( _broadcast_axis ( a , b ) for ( a , b ) in zip ( shape1 , shape2 ) ) )
raises valueerror if broadcast fails .