code: def _get_ngs_extractor(ngs) -> Optional[types.DocLikeToSpans]:
      if ngs is None:
          return None
      elif callable(ngs):
          return ngs
      elif isinstance(ngs, int) or (
          isinstance(ngs, Collection)
          and all(isinstance(ng, int) for ng in ngs)
      ):
          return partial(ngrams, n=ngs)
      else:
          raise TypeError()
  
file_path: textacy/src/textacy/extract/basics.py
imports: from __future__ import annotations
  from functools import partial
  from typing import Collection, Iterable, Optional, Union
  from cytoolz import itertoolz
  from spacy.parts_of_speech import DET
  from spacy.tokens import Span, Token
  from ..None import constants, errors, types, utils
label_desc: Use image node_id 8 for calling a global function with example usage: _get_ngs_extractor(ngs) and returns: None, ngs, partial