code: def test_groupby_apply_with_dropna_for_multi_index(
      dropna, data, selected_data, levels
  ):
      # GH 35889
  
      df = pd.DataFrame(data)
      gb = df.groupby("groups", dropna=dropna)
      msg = "DataFrameGroupBy.apply operated on the grouping columns"
      with tm.assert_produces_warning(FutureWarning, match=msg):
          result = gb.apply(
              lambda grp: pd.DataFrame({"values": range(len(grp))})
          )
  
      mi_tuples = tuple(zip(data["groups"], selected_data["values"]))
      mi = pd.MultiIndex.from_tuples(mi_tuples, names=["groups", None])
      # Since right now, by default MI will drop NA from levels when we create MI
      # via `from_*`, so we need to add NA for level manually afterwards.
      if not dropna and levels:
          mi = mi.set_levels(levels, level="groups")
  
      expected = pd.DataFrame(selected_data, index=mi)
      tm.assert_frame_equal(result, expected)
  
imports: import numpy
  import pytest
  from pandas.compat.pyarrow import pa_version_under10p1
  from pandas.core.dtypes.missing import na_value_for_dtype
  import pandas
  import pandas._testing
  from pandas.tests.groupby import get_groupby_method_args
label_desc: Use image node_id 10 for calling a global function with example usage: test_groupby_apply_with_dropna_for_multi_index(dropna, data, selected_data, levels) without return types