def _ensure_doc(self, doc_like: Union[str, Doc, bytes]) -> Doc:
        """Create a Doc if need be, or raise an error if the input is not
        a Doc, string, or a byte array (generated by Doc.to_bytes())."""
        if isinstance(doc_like, Doc):
            return doc_like
        if isinstance(doc_like, str):
            return self.make_doc(doc_like)
        if isinstance(doc_like, bytes):
            return Doc(self.vocab).from_bytes(doc_like)
        raise ValueError(Errors.E1041.format(type=type(doc_like)))
Create a Doc if need be, or raise an error if the input is not
        a Doc, string, or a byte array (generated by Doc.to_bytes()).
spacy/language.py