code: def test_choice():
      t = choice(5, chunk_size=1)
      assert t.shape == ()
      t = tile(t)
      assert t.nsplits == ()
      assert len(t.chunks) == 1
  
      t = choice(5, 3, chunk_size=1)
      assert t.shape == (3,)
      t = tile(t)
      assert t.nsplits == ((1, 1, 1),)
  
      t = choice(5, 3, replace=False)
      assert t.shape == (3,)
  
      with pytest.raises(ValueError):
          choice(-1)
  
      # a should be 1-d
      with pytest.raises(ValueError):
          choice(np.random.rand(2, 2))
  
      # p sum != 1
      with pytest.raises(ValueError):
          choice(np.random.rand(3), p=[0.2, 0.2, 0.2])
  
      # p should b 1-d
      with pytest.raises(ValueError):
          choice(np.random.rand(3), p=[[0.2, 0.6, 0.2]])
  
      # replace=False, choice size cannot be greater than a.size
      with pytest.raises(ValueError):
          choice(np.random.rand(10), 11, replace=False)
  
      # replace=False, choice size cannot be greater than a.size
      with pytest.raises(ValueError):
          choice(np.random.rand(10), (3, 4), replace=False)
  
file_path: mars/mars/tensor/random/tests/test_random.py
imports: import numpy
  import pytest
  from ....core import tile
  from ....serialization import serialize, deserialize
  from ....serialization.serializables import Serializable
  from ...datasource import tensor
  from ..None import beta, rand, choice, multivariate_normal, randint, randn, permutation, TensorPermutation, shuffle, RandomState
  from ..core import RandomStateField
label_desc: Use image node_id 4 for calling a global function with example usage: test_choice() without return types