code: def index_based_complete(self, text: str, line: str, begidx: int, endidx: int,
                               index_dict: Mapping[int, Union[Iterable, Callable]],
                               all_else: Union[None, Iterable, Callable] = None) -> List[str]:
          
          # Get all tokens through the one being completed
          tokens, _ = self.tokens_for_completion(line, begidx, endidx)
          if not tokens:
              return []
  
          matches = []
  
          # Get the index of the token being completed
          index = len(tokens) - 1
  
          # Check if token is at an index in the dictionary
          if index in index_dict:
              match_against = index_dict[index]
          else:
              match_against = all_else
  
          # Perform tab completion using a Collection
          if isinstance(match_against, Collection):
              matches = self.basic_complete(text, line, begidx, endidx, match_against)
  
          # Perform tab completion using a function
          elif callable(match_against):
              matches = match_against(text, line, begidx, endidx)
  
          return matches
docs: Tab completes based on a fixed position in the input string
          :param text: the string prefix we are attempting to match (all returned matches must begin with it)
          :param line: the current input line with leading whitespace removed
          :param begidx: the beginning index of the prefix text
          :param endidx: the ending index of the prefix text
          :param index_dict: dictionary whose structure is the following:
                             keys - 0-based token indexes into command line that determine which tokens
                                    perform tab completion
                             values - there are two types of values
                                1. iterable list of strings to match against (dictionaries, lists, etc.)
                                2. function that performs tab completion (ex: path_complete)
          :param all_else: an optional parameter for tab completing any token that isn't at an index in index_dict
          :return: a list of possible tab completions