code: def get_mask_index(obj):
      """Find all masked strings in obj and index them by mask id
  
      Parameters
      ----------
      obj : string, tuple, list, or dict
          Object (leaves must be strings, regardless of type)
  
      Returns
      -------
      tuple(dict, dict)
          First dict is a map from mask id to list of strings
          Second dict is a map from mask id to options
  
      """
      strings = get_all_strings(obj)
      # ?: after parenthesis makes group non-capturing
      mask_finder = re.compile(r"\{(?:[^\}]*:)?mask\d*\}")
      mask_rep = re.compile(r"[\{\}]")
      find_options = re.compile(r".*:")
      ret = collections.defaultdict(lambda: [])
      options = collections.defaultdict(lambda: "")
      for s in strings:
          masks = mask_finder.findall(s)
          nooptions = [
              mask_rep.sub("", find_options.sub("", x)) for x in masks
          ]
          ops = [
              find_options.search(mask_rep.sub("", x)) for x in masks
          ]
          ops = [x.group().strip(":") for x in ops if x]
          if len(set(nooptions)) > 1:
              raise Exception(
                  "Can only have one mask index per template string"
              )
          if nooptions:
              ret[nooptions[0]].append(s)
              options[nooptions[0]] += "".join(ops)
      return ret, options
  
imports: import collections
  import itertools
  import string
  import numpy
  import re
  import copy
  import os
  import json
  import munch
  import pickle
  import csv
  from .viewer.template_editor import TemplateEditor
  from .multilingual import multilingual_params, get_language_code
label_desc: Use image node_id 6 for calling a global function with example usage: get_mask_index(obj) and returns: ret,  options