def apply(<EOL>self, doc_loader, clear=True, parallelism=None, progress_bar=True, **kwargs<EOL>):
<EOL>if clear:<EOL><INDENT>self.clear(**kwargs)<EOL><DEDENT>self.last_docs = set(doc.name for doc in doc_loader)<EOL>self.logger.info("<STR_LIT>")<EOL>if progress_bar:<EOL><INDENT>self.logger.debug("<STR_LIT>")<EOL>if hasattr(doc_loader, "<STR_LIT>"):<EOL><INDENT>self.pb = tqdm(total=len(doc_loader))<EOL><DEDENT>else:<EOL><INDENT>self.logger.error("<STR_LIT>")<EOL><DEDENT><DEDENT>parallelism = parallelism if parallelism else self.parallelism<EOL>if parallelism < <NUM_LIT:2>:<EOL><INDENT>self._apply_st(doc_loader, clear=clear, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>self._apply_mt(doc_loader, parallelism, clear=clear, **kwargs)<EOL><DEDENT>if self.pb is not None:<EOL><INDENT>self.logger.debug("<STR_LIT>")<EOL>self.pb.close()<EOL><DEDENT>
Apply the given UDF to the set of objects returned by the doc_loader, either
single or multi-threaded, and optionally calling clear() first.