#NEWLINE# def broadcast_variables( * variables ) : #NEWLINE# #INDENT# "Given any number of variables, return variables with matching dimensions\n    and broadcast data.\n\n    The data on the returned variables will be a view of the data on the\n    corresponding original arrays, but dimensions will be reordered and\n    inserted so that both broadcast arrays have the same dimensions. The new\n    dimensions are sorted in order of appearence in the first variable's\n    dimensions followed by the second variable's dimensions.\n    " #NEWLINE# dims_map = _unified_dims ( variables ) #NEWLINE# dims_tuple = tuple ( dims_map ) #NEWLINE# return tuple ( ( ( var . expand_dims ( dims_map ) if ( variables . dims != dims_tuple ) else var ) for var in variables ) )