code: def test_xarray_cftimeindex_nearest():
      # https://github.com/pydata/xarray/issues/3751
      cftime = pytest.importorskip("cftime")
      xarray = pytest.importorskip("xarray")
  
      times = xarray.cftime_range("0001", periods=2)
      key = cftime.DatetimeGregorian(2000, 1, 1)
      result = times.get_indexer([key], method="nearest")
      expected = 1
      assert result == expected
  
imports: import array
  from functools import partial
  import subprocess
  import sys
  import numpy
  import pytest
  from pandas.errors import IntCastingNaNError
  import pandas
  from pandas import DataFrame, DatetimeIndex, Series, TimedeltaIndex
  import pandas._testing
  from pandas.core.arrays import DatetimeArray, TimedeltaArray
label_desc: Use image node_id 6 for calling a global function with example usage: test_xarray_cftimeindex_nearest() without return types