code: def n_words(doc_or_tokens: types.DocOrTokens) -> int:
      """
      Compute the number of words in a document.
  
      Args:
          doc_or_tokens: If a spaCy ``Doc``, non-punctuation tokens (words) are extracted;
              if an iterable of spaCy ``Token`` s, all non-punct elements are used.
      """
      words = utils.get_words(doc_or_tokens)
      return itertoolz.count(words)
  
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 2 for calling a global function with example usage: n_words(doc_or_tokens) and returns: itertoolz