code: def test_na_levels():
      # GH26408
      # test if codes are re-assigned value -1 for levels
      # with missing values (NaN, NaT, None)
      result = MultiIndex(
          levels=[[np.nan, None, pd.NaT, 128, 2]],
          codes=[[0, -1, 1, 2, 3, 4]],
      )
      expected = MultiIndex(
          levels=[[np.nan, None, pd.NaT, 128, 2]],
          codes=[[-1, -1, -1, -1, 3, 4]],
      )
      tm.assert_index_equal(result, expected)
  
      result = MultiIndex(
          levels=[[np.nan, "s", pd.NaT, 128, None]],
          codes=[[0, -1, 1, 2, 3, 4]],
      )
      expected = MultiIndex(
          levels=[[np.nan, "s", pd.NaT, 128, None]],
          codes=[[-1, -1, 1, -1, 3, -1]],
      )
      tm.assert_index_equal(result, expected)
  
      # verify set_levels and set_codes
      result = MultiIndex(
          levels=[[1, 2, 3, 4, 5]], codes=[[0, -1, 1, 2, 3, 4]]
      ).set_levels([[np.nan, "s", pd.NaT, 128, None]])
      tm.assert_index_equal(result, expected)
  
      result = MultiIndex(
          levels=[[np.nan, "s", pd.NaT, 128, None]],
          codes=[[1, 2, 2, 2, 2, 2]],
      ).set_codes([[0, -1, 1, 2, 3, 4]])
      tm.assert_index_equal(result, expected)
  
imports: from datetime import date, datetime
  import itertools
  import numpy
  import pytest
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  import pandas
  from pandas import Index, MultiIndex, Series, Timestamp, date_range
  import pandas._testing
label_desc: Use image node_id 5 for calling a global function with example usage: test_na_levels() without return types