<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tokenize_to_spacy_doc(self, text: str) -> Doc: """ Tokenize the given text, returning a spacy doc. Used for spacy rule extractor Args: text (string):
 Returns: Doc """

        if not self.keep_multi_space:
            text = re.sub(' +', ' ', text)
        doc = self.nlp(text, disable=['parser'])
        for a_token in doc:
            self.custom_token(a_token)

        return doc