code: def tags_to_regex(
      tag_pattern, format_dict=None, default_format="\\w+"
  ):
      r"""Converts a string with tags to regex.
  
      E.g. converts
          '/path/to/experiments/{model}/{task}'
      to
          '/path/to/experiments/(?P<model>\\w+)/(?P<task>\\w+)'
  
  
      Args:
          tag_pattern: str
              String with curly-brackets as tags
          format_dict: Dict[str, str]
              Special regex formatting for each tag
          default_format: str
              Default format if not format specified for tag in format_dict
  
      Returns: str
          regex string
      """
      if format_dict is None:
          format_dict = {}
      last_end = 0
      new_tokens = []
      for m in re.finditer("\\{(?P<tag>\\w+)\\}", tag_pattern):
          start, end = m.span()
          tag = m["tag"]
          new_tokens.append(tag_pattern[last_end:start])
          tag_format = format_dict.get(tag, default_format)
          new_tokens.append(f"(?P<{tag}>{tag_format})")
          last_end = end
      new_tokens.append(tag_pattern[last_end:])
      new_pattern = "".join(new_tokens)
      return new_pattern
  
imports: import glob
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: tags_to_regex(tag_pattern, format_dict, default_format) and returns: new_pattern