code: def n_sents(doc: Doc) -> int:
      """
      Compute the number of sentences in a document.
  
      Args:
          doc
  
      Warning:
          If ``doc`` has not been segmented into sentences, it will be modified in-place
          using spaCy's rule-based ``Sentencizer`` pipeline component before counting.
      """
      if not doc.has_annotation("SENT_START"):
          LOGGER.warning(
              "`doc` has not been segmented into sentences; applying spaCy's rule-based, "
              "`Sentencizer` pipeline component to `doc` before counting..."
          )
          doc = _SENTENCIZER(doc)
      return itertoolz.count(doc.sents)
  
imports: from __future__ import annotations
  import functools
  import logging
  import math
  from typing import Optional
  import spacy.pipeline
  from cytoolz import itertoolz
  from spacy.tokens import Doc
  from ..None import types
  from .None import utils
label_desc: Use image node_id 1 for calling a global function with example usage: n_sents(doc) and returns: itertoolz