code: def test_groupby_tabular_max(
      ray_start_regular_shared, ds_format, num_parts
  ):
      # Test built-in max aggregation
      seed = int(time.time())
      print(f"Seeding RNG for test_groupby_tabular_max with: {seed}")
      random.seed(seed)
      xs = list(range(100))
      random.shuffle(xs)
  
      def _to_pandas(ds):
          return ds.map_batches(
              lambda x: x, batch_size=None, batch_format="pandas"
          )
  
      ds = ray.data.from_items(
          [{"A": (x % 3), "B": x} for x in xs]
      ).repartition(num_parts)
      if ds_format == "pandas":
          ds = _to_pandas(ds)
  
      agg_ds = ds.groupby("A").max("B")
      assert agg_ds.count() == 3
      assert list(agg_ds.sort("A").iter_rows()) == [
          {"A": 0, "max(B)": 99},
          {"A": 1, "max(B)": 97},
          {"A": 2, "max(B)": 98},
      ]
  
      # Test built-in min aggregation with nans
      ds = ray.data.from_items(
          [{"A": (x % 3), "B": x} for x in xs] + [{"A": 0, "B": None}]
      ).repartition(num_parts)
      if ds_format == "pandas":
          ds = _to_pandas(ds)
      nan_grouped_ds = ds.groupby("A")
      nan_agg_ds = nan_grouped_ds.max("B")
      assert nan_agg_ds.count() == 3
      assert list(nan_agg_ds.sort("A").iter_rows()) == [
          {"A": 0, "max(B)": 99},
          {"A": 1, "max(B)": 97},
          {"A": 2, "max(B)": 98},
      ]
      # Test ignore_nulls=False
      nan_agg_ds = nan_grouped_ds.max("B", ignore_nulls=False)
      assert nan_agg_ds.count() == 3
      pd.testing.assert_frame_equal(
          nan_agg_ds.sort("A").to_pandas(),
          pd.DataFrame(
              {
                  "A": [0, 1, 2],
                  "max(B)": [None, 97, 98],
              }
          ),
          check_dtype=False,
      )
      # Test all nans
      ds = ray.data.from_items(
          [{"A": (x % 3), "B": None} for x in xs]
      ).repartition(num_parts)
      if ds_format == "pandas":
          ds = _to_pandas(ds)
      nan_agg_ds = ds.groupby("A").max("B")
      assert nan_agg_ds.count() == 3
      pd.testing.assert_frame_equal(
          nan_agg_ds.sort("A").to_pandas(),
          pd.DataFrame(
              {
                  "A": [0, 1, 2],
                  "max(B)": [None, None, None],
              }
          ),
          check_dtype=False,
      )
  
imports: import itertools
  import math
  import random
  import time
  from unittest.mock import patch
  import numpy
  import pandas
  import pyarrow
  import pytest
  import ray
  from ray.data.aggregate import AggregateFn, Count, Max, Mean, Min, Quantile, Std, Sum
  from ray.data.context import DataContext
  from ray.data.tests.conftest import *
  from ray.data.tests.util import column_udf, named_values
  from ray.tests.conftest import *
label_desc: Use image node_id 22 for calling a global function with example usage: test_groupby_tabular_max(ray_start_regular_shared, ds_format, num_parts) and returns: ds