code: def test_random_choice_without_replacement(ctx, func_name, seed):
      x = nn.Variable.from_numpy_array(
          np.array([0, 1, 2]).astype(np.int32)
      )
      w = nn.Variable.from_numpy_array(
          np.array([5, 5, 90]).astype(np.int32)
      )
      x.need_grad = True
      w.need_grad = True
      repeats = 1000
      with nn.context_scope(ctx):
          y = F.random_choice(
              x, w, shape=[w.size], replace=False, seed=seed
          )
      r = np.zeros((repeats, w.size)).astype(np.int32)
      for i in range(repeats):
          y.forward()
          r[i] = y.d.copy()
      assert np.all(np.bincount(r.flatten()) == x.size * [repeats])
  
      # Check recomputation
      from nbla_test_utils import recomputation_test
  
      rng = np.random.RandomState(0)
  
      x.d = np.random.random(*x.shape).astype(np.float32)
      w.d = np.random.randint(1, 100, w.size)
  
      vinputs = [x, w]
      func_kwargs = {"shape": (w.size,), "replace": False, "seed": seed}
  
      recomputation_test(
          rng=rng,
          func=F.random_choice,
          vinputs=vinputs,
          func_args=[],
          func_kwargs=func_kwargs,
          ctx=ctx,
      )
  
file_path: nnabla/python/test/function/test_random_choice.py
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nbla_test_utils import list_context
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 2 for calling a global function with example usage: test_random_choice_without_replacement(ctx, func_name, seed) without return types