def reduce(self, function, new_collection, initializer=None, **kwargs):
        """
        Reduces a collection into a new collection with a given function.

        | Arguments:
        | ``function`` -- The function used for reducing.
        | ``new_collection`` -- The name of the collection to insert the new value into.  
            Any existing values will be deleted.
            If ``None``, the current collection is replaced with the reduction output.

        | Keyword arguments:
        | ``create_if_missing`` -- when False a ValueError is raised if the new collection doesn't exist
        | ``error_if_exists`` -- When True a ValueError is raised if the new collection already exists 
        """
        reduced = None
        if initializer != None:
            reduced = reduce(function, self.iterator(), initializer)
        else:
            reduced = reduce(function, self.iterator())

        collection = None
        if new_collection in [None, self.name]:
            collection = self
        else:
            collection = self.parent_db.collection(new_collection, reset_collection=True, **kwargs)
        
        collection.append(reduced)
        return collection
dataset/ETHPy150Open corbt/pypeline/pypeline/DB.py/Collection.reduce/original