code: def get_spacy_model(
      spacy_model_name: str,
      pos_tags: bool,
      parse: bool,
      ner: bool,
      with_custom_tokenizer: bool = False,
      with_sentence_segmenter: bool = False,
      with_serializable_abbreviation_detector: Optional[bool] = None,
  ) -> SpacyModelType:
      """
      In order to avoid loading spacy models repeatedly,
      we'll save references to them, keyed by the options
      we used to create the spacy model, so any particular
      configuration only gets loaded once.
      """
      options = (
          spacy_model_name,
          pos_tags,
          parse,
          ner,
          with_custom_tokenizer,
          with_sentence_segmenter,
          with_serializable_abbreviation_detector,
      )
      if options not in LOADED_SPACY_MODELS:
          disable = ["vectors", "textcat"]
          if not pos_tags:
              disable.append("tagger")
          if not parse:
              disable.append("parser")
          if not ner:
              disable.append("ner")
          try:
              spacy_model = spacy.load(
                  spacy_model_name, disable=disable
              )
          except OSError:
              print(
                  f"Spacy models '{spacy_model_name}' not found.  Downloading and installing."
              )
              spacy_download(spacy_model_name)
              spacy_model = spacy.load(
                  spacy_model_name, disable=disable
              )
  
          if with_custom_tokenizer:
              spacy_model.tokenizer = combined_rule_tokenizer(
                  spacy_model
              )
          if with_sentence_segmenter:
              spacy_model.add_pipe("pysbd_sentencizer", first=True)
          if with_serializable_abbreviation_detector is not None:
              spacy_model.add_pipe(
                  "abbreviation_detector",
                  config={
                      "make_serializable": with_serializable_abbreviation_detector
                  },
              )
  
          LOADED_SPACY_MODELS[options] = spacy_model
      return LOADED_SPACY_MODELS[options]
  
imports: from typing import Dict, Tuple, Optional
  import os
  import pytest
  import spacy
  from spacy.language import Language
  from spacy.cli.download import download
  from scispacy.custom_sentence_segmenter import pysbd_sentencizer
  from scispacy.custom_tokenizer import combined_rule_tokenizer, combined_rule_prefixes, remove_new_lines
  from scispacy.abbreviation import AbbreviationDetector
label_desc: Use image node_id 1 for calling a global function with example usage: get_spacy_model(spacy_model_name, pos_tags, parse, ner, with_custom_tokenizer, with_sentence_segmenter, with_serializable_abbreviation_detector) and returns: LOADED_SPACY_MODELS