code: def include_sentence(sentence_patterns) -> bool:
      """
      Determines whether to use a sentence for upsampling whose patterns are provided as input. This will check the global pattern tables
      if this sentence includes any patterns that are still needed.
  
      Args:
          sentence_patterns: dictionary of patterns for a sentence grouped by class
      Returns:
          include: whether or not to use the sentence or for upsampling
      """
      include = False
      for k, v in sentence_patterns["MONEY"].items():
          if (
              v > 0
              and k in MONEY_PATTERNS
              and MONEY_PATTERNS[k] < args.min_number
          ):
              include = True
      for k, v in sentence_patterns["MEASURE"].items():
          if (
              v > 0
              and k in MEASURE_PATTERNS
              and MEASURE_PATTERNS[k] < args.min_number
          ):
              include = True
      for k, v in sentence_patterns["TIME"].items():
          if (
              v > 0
              and k in TIME_PATTERNS
              and TIME_PATTERNS[k] < args.min_number
          ):
              include = True
      for k, v in sentence_patterns["FRACTION"].items():
          if (
              v > 0
              and k in FRACTION_PATTERNS
              and FRACTION_PATTERNS[k] < args.min_number
          ):
              include = True
  
      if include:
          for k, v in sentence_patterns["MONEY"].items():
              if v > 0 and k in MONEY_PATTERNS:
                  MONEY_PATTERNS[k] += v
                  if (
                      MONEY_PATTERNS[k] - v < args.min_number
                      and MONEY_PATTERNS[k] >= args.min_number
                  ):
                      classes_to_upsample["MONEY"] -= 1
                      if classes_to_upsample["MONEY"] <= 0:
                          classes_to_upsample.pop("MONEY")
          for k, v in sentence_patterns["MEASURE"].items():
              if v > 0 and k in MEASURE_PATTERNS:
                  MEASURE_PATTERNS[k] += v
                  if (
                      MEASURE_PATTERNS[k] - v < args.min_number
                      and MEASURE_PATTERNS[k] >= args.min_number
                  ):
                      classes_to_upsample["MEASURE"] -= 1
                      if classes_to_upsample["MEASURE"] <= 0:
                          classes_to_upsample.pop("MEASURE")
          for k, v in sentence_patterns["TIME"].items():
              if v > 0 and k in TIME_PATTERNS:
                  TIME_PATTERNS[k] += v
                  if (
                      TIME_PATTERNS[k] - v < args.min_number
                      and TIME_PATTERNS[k] >= args.min_number
                  ):
                      classes_to_upsample["TIME"] -= 1
                      if classes_to_upsample["TIME"] <= 0:
                          classes_to_upsample.pop("TIME")
          for k, v in sentence_patterns["FRACTION"].items():
              if v > 0 and k in FRACTION_PATTERNS:
                  FRACTION_PATTERNS[k] += v
                  if (
                      FRACTION_PATTERNS[k] - v < args.min_number
                      and FRACTION_PATTERNS[k] >= args.min_number
                  ):
                      classes_to_upsample["FRACTION"] -= 1
                      if classes_to_upsample["FRACTION"] <= 0:
                          classes_to_upsample.pop("FRACTION")
      return include
  
file_path: NeMo/examples/nlp/duplex_text_normalization/data/en/upsample.py
imports: import glob
  from argparse import ArgumentParser
  from collections import defaultdict
  from typing import List
  import numpy
  import regex
label_desc: Use image node_id 1 for calling a global function with example usage: include_sentence(sentence_patterns) and returns: include