def __call__(self, batch_docs: List[Union[str, List[str]]]) ->List[Union[List[str], List[List[str]]]]:
result = []<EOL>for docs in batch_docs:<EOL><INDENT>batch_chunks = []<EOL>if isinstance(docs, str):<EOL><INDENT>docs = [docs]<EOL><DEDENT>for doc in docs:<EOL><INDENT>if self.paragraphs:<EOL><INDENT>split_doc = doc.split('<STR_LIT>')<EOL>split_doc = [sd.strip() for sd in split_doc]<EOL>split_doc = list(filter(lambda x: len(x) > <NUM_LIT>, split_doc))<EOL>batch_chunks.append(split_doc)<EOL><DEDENT>else:<EOL><INDENT>doc_chunks = []<EOL>if self.keep_sentences:<EOL><INDENT>sentences = sent_tokenize(doc)<EOL>n_tokens = <NUM_LIT:0><EOL>keep = []<EOL>for s in sentences:<EOL><INDENT>n_tokens += len(s.split())<EOL>if n_tokens > self.tokens_limit:<EOL><INDENT>if keep:<EOL><INDENT>doc_chunks.append('<STR_LIT:U+0020>'.join(keep))<EOL>n_tokens = <NUM_LIT:0><EOL>keep.clear()<EOL><DEDENT><DEDENT>keep.append(s)<EOL><DEDENT>if keep:<EOL><INDENT>doc_chunks.append('<STR_LIT:U+0020>'.join(keep))<EOL><DEDENT>batch_chunks.append(doc_chunks)<EOL><DEDENT>else:<EOL><INDENT>split_doc = doc.split()<EOL>doc_chunks = [split_doc[i:i + self.tokens_limit] for i in<EOL>range(<NUM_LIT:0>, len(split_doc), self.tokens_limit)]<EOL>batch_chunks.append(doc_chunks)<EOL><DEDENT><DEDENT><DEDENT>result.append(batch_chunks)<EOL><DEDENT>if self.flatten_result:<EOL><INDENT>if isinstance(result[<NUM_LIT:0>][<NUM_LIT:0>], list):<EOL><INDENT>for i in range(len(result)):<EOL><INDENT>flattened = list(chain.from_iterable(result[i]))<EOL>result[i] = flattened<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>
Make chunks from a batch of documents. There can be several documents in each batch.
        Args:
            batch_docs: a batch of documents / a batch of lists of documents
        Returns:
            chunks of docs, flattened or not