code: def test_custom_index():
      tsa_model.__warningregistry__ = {}
  
      endog = pd.Series(
          np.random.normal(size=5), index=["a", "b", "c", "d", "e"]
      )
      message = (
          "An unsupported index was provided. As a result, forecasts cannot be "
          "generated. To use the model for forecasting, use on the the "
          "supported classes of index."
      )
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
  
          mod = tsa_model.TimeSeriesModel(endog)
          # Change due to pandas changes that produce a warning
          messages = [str(warn.message) for warn in w]
          assert message in messages
      start_key = -2
      end_key = -1
      (
          start,
          end,
          out_of_sample,
          prediction_index,
      ) = mod._get_prediction_index(start_key, end_key)
  
      # Test the default output index
      assert_equal(prediction_index.equals(pd.Index(["d", "e"])), True)
  
      # Test custom output index
      (
          start,
          end,
          out_of_sample,
          prediction_index,
      ) = mod._get_prediction_index(
          start_key, end_key, index=["f", "g"]
      )
      assert_equal(prediction_index.equals(pd.Index(["f", "g"])), True)
  
      # Test getting a location in the index w/o fallback to row labels
      loc, index, index_was_expanded = mod._get_index_loc(2)
      assert_equal(loc, 2)
      assert_equal(index.equals(pd.RangeIndex(0, 3)), True)
      assert_equal(index_was_expanded, False)
      assert_equal(index_was_expanded, False)
  
      # Test getting an invalid location in the index w/ fallback to row labels
      with pytest.raises(KeyError):
          mod._get_index_loc("c")
  
      # Test getting a location in the index w/ fallback to row labels
      loc, index, index_was_expanded = mod._get_index_label_loc("c")
      assert_equal(loc, 2)
      assert_equal(index.equals(pd.Index(["a", "b", "c"])), True)
      assert_equal(index_was_expanded, False)
  
      # Test getting an invalid location in the index w/ fallback to row labels
      with pytest.raises(KeyError):
          mod._get_index_label_loc("aa")
  
      # Test out-of-sample
      start_key = 4
      end_key = 5
      message = (
          "No supported index is available. In the next version, calling this "
          "method in a model without a supported index will result in an "
          "exception."
      )
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
  
          (
              start,
              end,
              out_of_sample,
              prediction_index,
          ) = mod._get_prediction_index(start_key, end_key)
          assert_equal(prediction_index.equals(pd.Index([4, 5])), True)
          assert_equal(str(w[0].message), message)
  
      # Test out-of-sample custom index
      (
          start,
          end,
          out_of_sample,
          prediction_index,
      ) = mod._get_prediction_index(
          start_key, end_key, index=["f", "g"]
      )
      assert_equal(prediction_index.equals(pd.Index(["f", "g"])), True)
  
      # Test invalid custom index
      assert_raises(
          ValueError,
          mod._get_prediction_index,
          start_key,
          end_key,
          index=["f", "g", "h"],
      )
  
imports: from statsmodels.compat.pandas import PD_LT_2_2_0, YEAR_END, is_int_index
  import warnings
  import numpy
  from numpy.testing import assert_equal, assert_raises
  import pandas
  import pytest
  from statsmodels.tools.sm_exceptions import ValueWarning
  from statsmodels.tsa.base import tsa_model
label_desc: Use image node_id 11 for calling a global function with example usage: test_custom_index() without return types