code: def test_groupby_nunique_level(setup, gen_data1, gen_data3):
      df = gen_data1
      mdf = md.DataFrame(df, chunk_size=13)
  
      r = (
          mdf.groupby(level=0, as_index=False, sort=False)["a"]
          .nunique()
          .execute()
          .fetch()
      )
  
      expected = df.groupby(level=0, as_index=False, sort=False)[
          "a"
      ].nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf.groupby(level=0, sort=False)["a"]
          .nunique()
          .execute()
          .fetch()
      )
      expected = df.groupby(level=0, sort=False)["a"].nunique()
      pd.testing.assert_series_equal(r, expected, check_index=False)
  
      r = (
          mdf.groupby(level=0, sort=False)["a", "b"]
          .nunique()
          .execute()
          .fetch()
      )
      expected = df.groupby(level=0, sort=False)["a", "b"].nunique()
      pd.testing.assert_frame_equal(
          r.reset_index(drop=True), expected.reset_index(drop=True)
      )
  
      df2 = gen_data3
      mdf2 = md.DataFrame(df2, chunk_size=2)
      r = (
          mdf2.groupby(level="Type", sort=False)
          .nunique()
          .execute()
          .fetch()
      )
      expected = df2.groupby(level="Type", sort=False).nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf2.groupby(level=["Animal", "Type"], sort=False)
          .nunique()
          .execute()
          .fetch()
      )
      expected = df2.groupby(
          level=["Animal", "Type"], sort=False
      ).nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf2.groupby(level=(0, 1), sort=False)
          .nunique()
          .execute()
          .fetch()
      )
      expected = df2.groupby(level=(0, 1), sort=False).nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf2.groupby(level=["Type", "Animal"])
          .nunique()
          .execute()
          .fetch()
      )
      expected = df2.groupby(level=["Type", "Animal"]).nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf2.groupby(level=(0, 1), sort=False)
          .nunique(method="shuffle")
          .execute()
          .fetch()
      )
      expected = df2.groupby(level=(0, 1), sort=False).nunique()
      pd.testing.assert_frame_equal(
          r.sort_index(), expected.sort_index()
      )
  
      r = (
          mdf2.groupby(level=["Type", "Animal"])
          .nunique(method="tree")
          .execute()
          .fetch()
      )
      expected = df2.groupby(level=["Type", "Animal"]).nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf2.groupby(level=["Type", "Animal"])
          .nunique(method="auto")
          .execute()
          .fetch()
      )
      expected = df2.groupby(level=["Type", "Animal"]).nunique()
      pd.testing.assert_frame_equal(r, expected)
  
      r = (
          mdf2.groupby(level=["Type", "Animal"], sort=False)
          .nunique(method="shuffle")
          .execute()
          .fetch()
      )
      expected = df2.groupby(level=["Type", "Animal"]).nunique()
      pd.testing.assert_frame_equal(
          r.sort_index(), expected.sort_index()
      )
  
file_path: mars/mars/dataframe/groupby/tests/test_groupby_nunique_execution.py
imports: import numpy
  import pandas
  import pytest
  from ....None import dataframe
label_desc: Use image node_id 10 for calling a global function with example usage: test_groupby_nunique_level(setup, gen_data1, gen_data3) without return types