def get_output_attribute(out, attribute_name, cuda_device):
    """
    This function handles processing/reduction of output for both
    DataParallel or non-DataParallel situations.
    For the case of multiple GPUs, This function will
    sum all values for a certain output attribute in various batches
    together.

    Parameters
    ---------------------
    out: Dictionary, output of model during forward pass,
    attribute_name: str,
    cuda_device: list or int
    """
    if isinstance(cuda_device, list):
        return out[attribute_name].sum()
    else:
        return out[attribute_name]