code: def mtld(
      doc_or_tokens: types.DocOrTokens, min_ttr: float = 0.72
  ) -> float:
      """
      Compute the Measure of Textual Lexical Diversity (MTLD) of ``doc_or_tokens``,
      the average length of the longest consecutive sequences of words that maintain a TTR
      of at least ``min_ttr``.
  
      Higher values indicate higher lexical diversity.
  
      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.
          min_ttr: Minimum TTR for each segment in ``doc_or_tokens``. When an ongoing
              segment's TTR falls below this value, a new segment is started.
              Value should be in the range [0.66, 0.75].
  
      References:
          McCarthy, P. M., & Jarvis, S. (2010). MTLD, vocd-D, and HD-D: A validation study
          of sophisticated approaches to lexical diversity assessment. Behavior research
          methods, 42(2), 381-392.
      """
      words = tuple(utils.get_words(doc_or_tokens))
      return statistics.mean(
          [
              _mtld_run(words, min_ttr),
              _mtld_run(reversed(words), min_ttr),
          ]
      )
  
file_path: textacy/src/textacy/text_stats/diversity.py
imports: from __future__ import annotations
  import logging
  import math
  import statistics
  from typing import Iterable, Literal
  from scipy.stats import hypergeom
  from spacy.tokens import Token
  from toolz import itertoolz
  from ..None import errors, types
  from .None import utils
label_desc: Use image node_id 4 for calling a global function with example usage: mtld(doc_or_tokens, min_ttr) and returns: statistics