code: def test_merge_datetime_index(self, klass):
      # see gh-19038
      df = DataFrame(
          [1, 2, 3],
          ["2016-01-01", "2017-01-01", "2018-01-01"],
          columns=["a"],
      )
      df.index = pd.to_datetime(df.index)
      on_vector = df.index.year
  
      if klass is not None:
          on_vector = klass(on_vector)
  
      exp_years = np.array([2016, 2017, 2018], dtype=np.int32)
      expected = DataFrame({"a": [1, 2, 3], "key_1": exp_years})
  
      result = df.merge(df, on=["a", on_vector], how="inner")
      tm.assert_frame_equal(result, expected)
  
      expected = DataFrame(
          {"key_0": exp_years, "a_x": [1, 2, 3], "a_y": [1, 2, 3]}
      )
  
      result = df.merge(df, on=[df.index.year], how="inner")
      tm.assert_frame_equal(result, expected)
  
imports: import numpy
  import pytest
  import pandas.util._test_decorators
  import pandas
  from pandas import DataFrame, Index, MultiIndex, RangeIndex, Series, Timestamp, option_context
  import pandas._testing
  from pandas.core.reshape.concat import concat
  from pandas.core.reshape.merge import merge
label_desc: Use image node_id 11 for calling the TestMergeMulti obj's underlying member method code with example usage: obj.test_merge_datetime_index(klass) without return types