code: def get_fieldset_index(fieldsets, index_or_name):
      
      if isinstance(index_or_name, six.integer_types):
          return index_or_name
  
      for key, value in enumerate(fieldsets):
          if value[0] == index_or_name:
              return key
  
      raise KeyError("Key not found: '{}'.".format(index_or_name))
docs: Return the index of a fieldset in the ``fieldsets`` list.
  
      Args:
          fieldsets (list): The original ``fieldsets`` list.
          index_or_name (int or str): The value of the reference element, or directly its numeric index.
  
      Returns:
          (int) The index of the fieldset in the ``fieldsets`` list.