code: def test_nan_multi_index(all_parsers):
      # GH 42446
      parser = all_parsers
      data = "A,B,B\nX,Y,Z\n1,2,inf"
  
      if parser.engine == "pyarrow":
          msg = "The pyarrow engine doesn't support passing a dict for na_values"
          with pytest.raises(ValueError, match=msg):
              parser.read_csv(
                  StringIO(data),
                  header=list(range(2)),
                  na_values={("B", "Z"): "inf"},
              )
          return
  
      result = parser.read_csv(
          StringIO(data),
          header=list(range(2)),
          na_values={("B", "Z"): "inf"},
      )
  
      expected = DataFrame(
          {
              ("A", "X"): [1],
              ("B", "Y"): [2],
              ("B", "Z"): [np.nan],
          }
      )
  
      tm.assert_frame_equal(result, expected)
  
imports: from io import StringIO
  import numpy
  import pytest
  from pandas._libs.parsers import STR_NA_VALUES
  from pandas import DataFrame, Index, MultiIndex
  import pandas._testing
label_desc: Use image node_id 26 for calling a global function with example usage: test_nan_multi_index(all_parsers) without return types