code: def train(
      config_path: Union[str, Path],
      output_path: Optional[Union[str, Path]] = None,
      *,
      use_gpu: int = -1,
      overrides: Dict[str, Any] = util.SimpleFrozenDict(),
  ):
      config_path = util.ensure_path(config_path)
      output_path = util.ensure_path(output_path)
      # Make sure all files and paths exists if they are needed
      if not config_path or (
          str(config_path) != "-" and not config_path.exists()
      ):
          msg.fail("Config file not found", config_path, exits=1)
      if not output_path:
          msg.info("No output directory provided")
      else:
          if not output_path.exists():
              output_path.mkdir(parents=True)
              msg.good(f"Created output directory: {output_path}")
          msg.info(f"Saving to output directory: {output_path}")
      setup_gpu(use_gpu)
      with show_validation_error(config_path):
          config = util.load_config(
              config_path, overrides=overrides, interpolate=False
          )
      msg.divider("Initializing pipeline")
      with show_validation_error(config_path, hint_fill=False):
          nlp = init_nlp(config, use_gpu=use_gpu)
      msg.good("Initialized pipeline")
      msg.divider("Training pipeline")
      train_nlp(
          nlp,
          output_path,
          use_gpu=use_gpu,
          stdout=sys.stdout,
          stderr=sys.stderr,
      )
  
file_path: spaCy/spacy/cli/train.py
imports: import logging
  import sys
  from pathlib import Path
  from typing import Any, Dict, Optional, Union
  import typer
  from wasabi import msg
  from ..None import util
  from ..training.initialize import init_nlp
  from ..training.loop import train
  from ._util import Arg, Opt, app, import_code, parse_config_overrides, setup_gpu, show_validation_error
label_desc: Use image node_id 2 for calling a global function with example usage: train(config_path, output_path) without return types