code: def test_random_sample_without_replacement(
      weights,
      num_samples,
      expected_count,
      tolerance,
      raises_exception,
      device_id,
      precision,
  ):
      weights = AA(weights, precision)
      identity = np.identity(weights.size)
      allow_duplicates = False  # sample without replacement
  
      if raises_exception:
          with pytest.raises(ValueError):
              result = random_sample(
                  weights, num_samples, allow_duplicates
              )
              result.eval()
      else:
          result = random_sample(weights, num_samples, allow_duplicates)
          denseResult = times(result, identity)
          observed_count = np.sum(denseResult.eval(), 0)
          assert np.allclose(
              observed_count, expected_count, atol=tolerance
          )
  
file_path: CNTK/bindings/python/cntk/ops/tests/random_sample_test.py
imports: from __future__ import division
  import numpy
  import pytest
  from .ops_test_utils import AA, precision
  from cntk import random_sample_inclusion_frequency, random_sample, times
label_desc: Use image node_id 3 for calling a global function with example usage: test_random_sample_without_replacement(weights, num_samples, expected_count, tolerance, raises_exception, device_id, precision) without return types