code: def sample_snippets_by_substitution(
      snippets_by_substitution: tuple[
          AbbrevExpansionPair, Sequence[tuple[str, WSRSFeatures]]
      ],
      num_snippets_per_substitution: int,
  ) -> Iterator[tuple[str, WSRSFeatures]]:
      """Samples a fixed number of snippets for each substitution pair."""
      limit = num_snippets_per_substitution
      if limit == 0:
          return
      snippets = snippets_by_substitution[1]
      for key, features in snippets:
          yield key, features
          limit -= 1
          if limit <= 0:
              break
  
file_path: datasets/tensorflow_datasets/text/c4_wsrs/c4_wsrs_utils.py
imports: from __future__ import annotations
  import collections
  import dataclasses
  import random
  import re
  from typing import Iterator, Mapping, Sequence, Tuple
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: sample_snippets_by_substitution(snippets_by_substitution, num_snippets_per_substitution) without return types