code: def test_assert_all_finite(setup):
      raw = np.array([2.3, np.inf], dtype=np.float64)
      x = mt.tensor(raw)
  
      with pytest.raises(ValueError):
          r = assert_all_finite(x)
          r.execute()
  
      raw = np.array([2.3, np.nan], dtype=np.float64)
      x = mt.tensor(raw)
  
      with pytest.raises(ValueError):
          r = assert_all_finite(x, allow_nan=False)
          r.execute()
  
      max_float32 = np.finfo(np.float32).max
      raw = [max_float32] * 2
      assert not np.isfinite(np.sum(raw))
      x = mt.tensor(raw)
  
      r = assert_all_finite(x)
      result = r.execute().fetch()
      assert result is True
  
      raw = np.array([np.nan, "a"], dtype=object)
      x = mt.tensor(raw)
  
      with pytest.raises(ValueError):
          r = assert_all_finite(x)
          r.execute()
  
      raw = np.random.rand(10)
      x = mt.tensor(raw, chunk_size=2)
  
      r = assert_all_finite(x, check_only=False)
      result = r.execute().fetch()
      np.testing.assert_array_equal(result, raw)
  
      r = assert_all_finite(x)
      result = r.execute().fetch()
      assert result is True
  
      with option_context() as options:
          options.learn.assume_finite = True
  
          assert assert_all_finite(x) is None
          assert assert_all_finite(x, check_only=False) is x
  
      # test sparse
      s = sps.random(
          10,
          3,
          density=0.1,
          format="csr",
          random_state=np.random.RandomState(0),
      )
      s[0, 2] = np.nan
  
      with pytest.raises(ValueError):
          r = assert_all_finite(s)
          r.execute()
  
file_path: mars/mars/learn/utils/tests/test_checks.py
imports: import numpy
  import pandas
  import pytest
  import scipy.sparse
  from ....None import tensor
  from ....None import dataframe
  from ....config import option_context
  from ..checks import check_non_negative_then_return_value, assert_all_finite
label_desc: Use image node_id 2 for calling a global function with example usage: test_assert_all_finite(setup) without return types