code: def _randomly_segment_text(
      text: str, len_range: Tuple[int, int]
  ) -> Iterable[str]:
      min_len, max_len = len_range
      idxs = []
      idx = 0
      while idx < len(text):
          idxs.append(idx)
          idx += random.randint(min_len, max_len)
      idxs.append(len(text))
      for idx_start, idx_end in itertoolz.sliding_window(2, idxs):
          yield text[idx_start:idx_end]
  
imports: from __future__ import annotations
  import logging
  import operator
  import pathlib
  import random
  import re
  from typing import Dict, Iterable, List, Optional, Set, Tuple
  from cytoolz import itertoolz
  import textacy
  import textacy.utils
  from textacy import io
label_desc: Use image node_id 1 for calling a global function with example usage: _randomly_segment_text(text, len_range) without return types