code: def test_global_tabular_sum(
      ray_start_regular_shared, ds_format, num_parts
  ):
      seed = int(time.time())
      print(f"Seeding RNG for test_global_arrow_sum 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"
          )
  
      # Test built-in global sum aggregation
      ds = ray.data.from_items([{"A": x} for x in xs]).repartition(
          num_parts
      )
      if ds_format == "pandas":
          ds = _to_pandas(ds)
      assert ds.sum("A") == 4950
  
      # Test empty dataset
      ds = ray.data.range(10)
      if ds_format == "pandas":
          ds = _to_pandas(ds)
      assert ds.filter(lambda r: r["id"] > 10).sum("id") is None
  
      # Test built-in global sum aggregation with nans
      nan_ds = ray.data.from_items(
          [{"A": x} for x in xs] + [{"A": None}]
      ).repartition(num_parts)
      if ds_format == "pandas":
          nan_ds = _to_pandas(nan_ds)
      assert nan_ds.sum("A") == 4950
      # Test ignore_nulls=False
      assert nan_ds.sum("A", ignore_nulls=False) is None
      # Test all nans
      nan_ds = ray.data.from_items([{"A": None}] * len(xs)).repartition(
          num_parts
      )
      if ds_format == "pandas":
          nan_ds = _to_pandas(nan_ds)
      assert nan_ds.sum("A") is None
      assert nan_ds.sum("A", ignore_nulls=False) is None
  
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 20 for calling a global function with example usage: test_global_tabular_sum(ray_start_regular_shared, ds_format, num_parts) and returns: ds