code: def get_index_label_loc(key, index, row_labels):
      """
      Get the location of a specific key in an index or model row labels
  
      Parameters
      ----------
      key : label
          The key for which to find the location if the underlying index is
          a DateIndex or is only being used as row labels, or a location if
          the underlying index is a RangeIndex or a NumericIndex.
      index : pd.Index
          The index to search.
      row_labels : pd.Index
          Row labels to search if key not found in index
  
      Returns
      -------
      loc : int
          The location of the key
      index : pd.Index
          The index including the key; this is a copy of the original index
          unless the index had to be expanded to accommodate `key`.
      index_was_expanded : bool
          Whether or not the index was expanded to accommodate `key`.
  
      Notes
      -----
      This function expands on `get_index_loc` by first trying the given
      base index (or the model's index if the base index was not given) and
      then falling back to try again with the model row labels as the base
      index.
      """
      try:
          loc, index, index_was_expanded = get_index_loc(key, index)
      except KeyError as e:
          try:
              if not isinstance(key, (int, np.integer)):
                  loc = row_labels.get_loc(key)
              else:
                  raise
              # Require scalar
              # Pandas may return a slice if there are multiple matching
              # locations that are monotonic increasing (otherwise it may
              # return an array of integer locations, see below).
              if isinstance(loc, slice):
                  loc = loc.start
              if isinstance(loc, np.ndarray):
                  # Pandas may return a mask (boolean array), for e.g.:
                  # pd.Index(list('abcb')).get_loc('b')
                  if loc.dtype == bool:
                      # Return the first True value
                      # (we know there is at least one True value if we're
                      # here because otherwise the get_loc call would have
                      # raised an exception)
                      loc = np.argmax(loc)
                  # Finally, Pandas may return an integer array of
                  # locations that match the given value, for e.g.
                  # pd.DatetimeIndex(['2001-02', '2001-01']).get_loc('2001')
                  # (this appears to be slightly undocumented behavior, since
                  # only int, slice, and mask are mentioned in docs for
                  # pandas.Index.get_loc as of 0.23.4)
                  else:
                      loc = loc[0]
              if not isinstance(loc, numbers.Integral):
                  raise
  
              index = row_labels[: loc + 1]
              index_was_expanded = False
          except:
              raise e
      return loc, index, index_was_expanded
  
imports: from __future__ import annotations
  from statsmodels.compat.pandas import is_float_index, is_int_index, is_numeric_dtype
  import numbers
  import warnings
  import numpy
  from pandas import DatetimeIndex, Index, Period, PeriodIndex, RangeIndex, Series, Timestamp, date_range, period_range, to_datetime
  from pandas.tseries.frequencies import to_offset
  from statsmodels.base.data import PandasData
  import statsmodels.base.model
  import statsmodels.base.wrapper
  from statsmodels.tools.sm_exceptions import ValueWarning
label_desc: Use image node_id 2 for calling a global function with example usage: get_index_label_loc(key, index, row_labels) and returns: loc,  index,  index_was_expanded