code: def test_real_reader(synthetic_dataset):
      readers = [
          make_reader(
              synthetic_dataset.url,
              predicate=in_lambda(["id"], lambda id: id % 2 == 0),
              num_epochs=None,
              reader_pool_type="dummy",
          ),
          make_reader(
              synthetic_dataset.url,
              predicate=in_lambda(["id"], lambda id: id % 2 == 1),
              num_epochs=None,
              reader_pool_type="dummy",
          ),
      ]
      results = [0, 0]
      num_of_reads = 300
      with WeightedSamplingReader(readers, [0.5, 0.5]) as mixer:
          # Piggyback on this test to verify container interface of the WeightedSamplingReader
          for i, sample in enumerate(mixer):
              next_id = sample.id % 2
              results[next_id] += 1
              if i >= num_of_reads:
                  break
  
      np.testing.assert_allclose(
          results,
          [num_of_reads * 0.5, num_of_reads * 0.5],
          atol=num_of_reads / 10,
      )
  
imports: from __future__ import division
  import numpy
  import pytest
  import six
  import tensorflow.compat.v1
  from petastorm import make_reader
  from petastorm.ngram import NGram
  from petastorm.predicates import in_lambda
  from petastorm.pytorch import DataLoader
  from petastorm.test_util.reader_mock import ReaderMock
  from petastorm.tf_utils import tf_tensors, make_petastorm_dataset
  from petastorm.unischema import Unischema, UnischemaField
  from petastorm.weighted_sampling_reader import WeightedSamplingReader
  from petastorm.tests.test_tf_utils import create_tf_graph
label_desc: Use image node_id 5 for calling a global function with example usage: test_real_reader(synthetic_dataset) without return types