code: def create_pattern(
      templates: List[str], input_str: str, pretty: bool = False
  ):
      """
      create all patterns based on list of input templates using the input string.
  
      Args:
          templates: list of templates/stencils
          input_str: string to apply templates on to create patterns
          pretty: used to pretty print patterns
      """
      res = defaultdict(int)
      for template in templates:
          if re.search(template, input_str) is None:
              continue
          if not pretty:
              res[re.sub(template, template, input_str)] += 1
          else:
              res[re.sub(template, "@", input_str)] += 1
      return res
  
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 6 for calling a global function with example usage: create_pattern(templates, input_str, pretty) and returns: res