code: def create_before_to_disk_callback(
      callback: Optional[Callable[["Language"], "Language"]]
  ) -> Callable[["Language"], "Language"]:
      from ..language import Language  # noqa: F811
  
      def before_to_disk(nlp: Language) -> Language:
          if not callback:
              return nlp
          modified_nlp = callback(nlp)
          if not isinstance(modified_nlp, Language):
              err = Errors.E914.format(
                  name="before_to_disk", value=type(modified_nlp)
              )
              raise ValueError(err)
          return modified_nlp
  
      return before_to_disk
  
file_path: spaCy/spacy/training/loop.py
imports: import random
  import shutil
  import sys
  from pathlib import Path
  from timeit import default_timer
  from typing import IO, TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
  from thinc.api import Config, Optimizer, constant, fix_random_seed, set_gpu_allocator
  from wasabi import Printer
  from ..errors import Errors
  from ..schemas import ConfigSchemaTraining
  from ..util import logger, registry, resolve_dot_names
  from .example import Example
label_desc: Use image node_id 7 for calling a global function with example usage: create_before_to_disk_callback(callback) and returns: before_to_disk, modified_nlp, nlp