code: def create_word_finder_regex(words: Sequence[str]) -> re.Pattern[str]:
      """Creates regex pattern that matches any of the provided words.
  
      The regex pattern is comprised of 3 components: the prefix, the words, and the
      suffix. The words are a concatenation of all provided words separated by the
      OR operator. The prefix and suffix ensure that the matched word represents a
      distinct, delineated instance of that word.
        - prefix: A word must be preceded by any one of the following patterns:
          1. The string start
          2. Any character OTHER than alphanumeric or apostrophe
          3. An apostrophe preceded by a non-alphanumeric character (this
            ensures contractions and possessives do not lead to false positives)
        - suffix: A word must be followed by any one of the following patterns:
          1. The string end
          2. Any non-alphanumeric character
      Note: the order of the words matters, as the regex pattern will greedily
      match with the first word in the list. This has implications for instances
      in which a word is a distinguishable substring of another word.
  
      Args:
        words: A list of words that the pattern will find.
  
      Returns:
        A regex pattern that will match any instance of the provided words.
      """
      words_re = "|".join([re.escape(word) for word in words])
      prefix_re = "^|[^\\w']|(?:^|\\W)'"
      suffix_re = "(?:$|\\W)"
      # We exclude the suffix from capture so that consecutive abbreviations
      # separated by spaces can be matched.
      re_string = f"(?:{prefix_re})({words_re})(?={suffix_re})"
      return re.compile(re_string)
  
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 2 for calling a global function with example usage: create_word_finder_regex(words) and returns: re