def mul_shapes(lh_shape, rh_shape):
 if (lh_shape == (1, 1)):
  return rh_shape
 elif (rh_shape == (1, 1)):
  return lh_shape
 else:
  if (lh_shape[1] != rh_shape[0]):
   raise ValueError(('Incompatible dimensions %s %s' % (lh_shape, rh_shape)))
  return (lh_shape[0], rh_shape[1])

def mul_shapes ( lh_shape , rh_shape ) : if ( lh_shape == ( 1 , 1 ) ) : return rh_shape elif ( rh_shape == ( 1 , 1 ) ) : return lh_shape else : if ( lh_shape [ 1 ] != rh_shape [ 0 ] ) : raise ValueError ( ( 'Incompatible dimensions %s %s' % ( lh_shape , rh_shape ) ) ) return ( lh_shape [ 0 ] , rh_shape [ 1 ] )
give the shape resulting from multiplying two shapes .