def broadcast_shapes(*args):
 x = (list(np.atleast_1d(args[0])) if args else ())
 for arg in args[1:]:
  y = list(np.atleast_1d(arg))
  if (len(x) < len(y)):
   (x, y) = (y, x)
  x[(- len(y)):] = [(j if (i == 1) else (i if (j == 1) else (i if (i == j) else 0))) for (i, j) in zip(x[(- len(y)):], y)]
  if (not all(x)):
   return None
 return tuple(x)

def broadcast_shapes ( * args ) : x = ( list ( np . atleast_1d ( args [ 0 ] ) ) if args else ( ) ) for arg in args [ 1 : ] : y = list ( np . atleast_1d ( arg ) ) if ( len ( x ) < len ( y ) ) : ( x , y ) = ( y , x ) x [ ( - len ( y ) ) : ] = [ ( j if ( i == 1 ) else ( i if ( j == 1 ) else ( i if ( i == j ) else 0 ) ) ) for ( i , j ) in zip ( x [ ( - len ( y ) ) : ] , y ) ] if ( not all ( x ) ) : return None return tuple ( x )
determines output shape from broadcasting arrays .