code: def test_select_distinct(self):
      # Tests that ChoiceFromUniform always selects distinct elements
  
      p = tensor.fmatrix()
      u = tensor.fvector()
      n = tensor.iscalar()
      m = multinomial.ChoiceFromUniform(odtype="auto")(p, u, n)
  
      f = function([p, u, n], m, allow_input_downcast=True)
  
      n_elements = 1000
      all_indices = range(n_elements)
      np.random.seed(12345)
      expected = [
          np.asarray([[931, 318, 185, 209, 559]]),
          np.asarray(
              [[477, 887, 2, 717, 333, 665, 159, 559, 348, 136]]
          ),
          np.asarray(
              [
                  [
                      546,
                      28,
                      79,
                      665,
                      295,
                      779,
                      433,
                      531,
                      411,
                      716,
                      244,
                      234,
                      70,
                      88,
                      612,
                      639,
                      383,
                      335,
                      451,
                      100,
                      175,
                      492,
                      848,
                      771,
                      559,
                      214,
                      568,
                      596,
                      370,
                      486,
                      855,
                      925,
                      138,
                      300,
                      528,
                      507,
                      730,
                      199,
                      882,
                      357,
                      58,
                      195,
                      705,
                      900,
                      66,
                      468,
                      513,
                      410,
                      816,
                      672,
                  ]
              ]
          ),
      ]
  
      for i in [5, 10, 50, 100, 500, n_elements]:
          uni = np.random.rand(i).astype(config.floatX)
          pvals = np.random.randint(1, 100, (1, n_elements)).astype(
              config.floatX
          )
          pvals /= pvals.sum(1)
          res = f(pvals, uni, i)
          for ii in range(len(expected)):
              if expected[ii].shape == res.shape:
                  assert (expected[ii] == res).all()
          res = np.squeeze(res)
          assert len(res) == i
          assert np.all(np.in1d(np.unique(res), all_indices)), res
  
file_path: Theano/theano/sandbox/tests/test_multinomial_wo_replacement.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import os
  from theano import config, function, tensor
  from theano.compat import PY3
  from theano.misc.pkl_utils import CompatUnpickler
  from theano.sandbox import multinomial
  from theano.sandbox.rng_mrg import MRG_RandomStreams
  import unittest
label_desc: Use image node_id 1 for calling the test_OP obj's underlying member method code with example usage: obj.test_select_distinct() without return types