<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def process_elements(self, func, cond=None, doc_ids=None, eids=None):
 """ Helper function for processing all documents specified by condition or IDs. A repeating pattern in TinyDB is to run some code on all documents that match a condition or are specified by their ID. This is implemented in this function. The function passed as ``func`` has to be a callable. Its first argument will be the data currently in the database. Its second argument is the document ID of the currently processed document. See: :meth:`~.update`, :meth:`.remove` :param func: the function to execute on every included document. first argument: all data second argument: the current eid :param cond: query that matches documents to use, or :param doc_ids: list of document IDs to use :param eids: list of document IDs to use (deprecated) :returns: the document IDs that were affected during processing """


        doc_ids = _get_doc_ids(doc_ids, eids)
        data = self._read()

        if doc_ids is not None:
            # Processed document specified by id
            for doc_id in doc_ids:
                func(data, doc_id)

        elif cond is not None:
            # Collect affected doc_ids
            doc_ids = []

            # Processed documents specified by condition
            for doc_id in list(data):
                if cond(data[doc_id]):
                    func(data, doc_id)
                    doc_ids.append(doc_id)
        else:
            # Processed documents
            doc_ids = list(data)

            for doc_id in doc_ids:
                func(data, doc_id)

        self._write(data)

        return doc_ids