def _ensure_doc_with_context(
        self, doc_like: Union[str, Doc, bytes], context: _AnyContext
    ) -> Doc:
        """Call _ensure_doc to generate a Doc and set its context object."""
        doc = self._ensure_doc(doc_like)
        doc._context = context
        return doc
Call _ensure_doc to generate a Doc and set its context object.
spacy/language.py