def train(self, output_dir: Optional[str] = None) -> None:
        """Train the pipeline using `spaCy`.

        Args:
            output_dir: A `str` with the path to save the trained pipeline. Defaults to None.
        """
        from spacy.training.initialize import init_nlp
        from spacy.training.loop import train as train_nlp

        self._logger.warning(
            "Note that the spaCy training is expected to be used through the CLI rather"
            " than programmatically, so the dataset needs to be dumped into the disk and"
            " then loaded from disk. More information at"
            " https://spacy.io/usage/training#api"
        )
        self._logger.info(f"Dumping the train dataset to {self._train_dataset_path}")
        self._train_dataset.to_disk(self._train_dataset_path)
        if self._eval_dataset:
            self._logger.info(f"Dumping the dev dataset to {self._eval_dataset_path}")
            self._eval_dataset.to_disk(self._eval_dataset_path)

        # Both `init_nlp` and `train_nlp` must be executed in the same Jupyter Notebook
        # cell if using the GPU, otherwise, since `thinc` is using `ContextVars` to
        # store the `Config` object, the `Config` object will be lost between cells and
        # the training will fail.
        self.trainer_model = init_nlp(self.trainer_kwargs, use_gpu=self.gpu_id)
        self.trainer_model, _ = train_nlp(self.trainer_model, use_gpu=self.gpu_id, stdout=sys.stdout, stderr=sys.stderr)

        if output_dir:
            self.save(output_dir)
Train the pipeline using `spaCy`.

        Args:
            output_dir: A `str` with the path to save the trained pipeline. Defaults to None.
        
argilla-v1/src/argilla_v1/training/spacy.py