code: def __init__(self, reader_0, reader_1, data_param, batch_size=1):
      Layer.__init__(self, name="pairwise_sampler_uniform")
      # reader for the fixed images
      self.reader_0 = reader_0
      # reader for the moving images
      self.reader_1 = reader_1
  
      # TODO:
      # 0) check the readers should have the same length file list
      # 1) detect window shape mismatches or defaulting
      #    windows to the fixed image reader properties
      # 2) reshape images to (supporting multi-modal data)
      #    [batch, x, y, channel] or [batch, x, y, z, channels]
      # 3) infer spatial rank
      # 4) make ``label`` optional
      self.batch_size = batch_size
      self.spatial_rank = 3
      self.window = ImageWindow.from_data_reader_properties(
          self.reader_0.input_sources,
          self.reader_0.shapes,
          self.reader_0.tf_dtypes,
          data_param,
      )
      if self.window.has_dynamic_shapes:
          tf.logging.fatal(
              "Dynamic shapes not supported.\nPlease specify "
              "all spatial dims of the input data, for the "
              "spatial_window_size parameter."
          )
          raise NotImplementedError
      # TODO: check spatial dims the same across input modalities
      self.image_shape = self.reader_0.shapes["fixed_image"][
          : self.spatial_rank
      ]
      self.moving_image_shape = self.reader_1.shapes["moving_image"][
          : self.spatial_rank
      ]
      self.window_size = self.window.shapes["fixed_image"][1:]
  
      # initialise a dataset prefetching pairs of image and label volumes
      n_subjects = len(self.reader_0.output_list)
      rand_ints = np.random.randint(n_subjects, size=[n_subjects])
      image_dataset = tf.data.Dataset.from_tensor_slices(rand_ints)
      # mapping random integer id to 4 volumes moving/fixed x image/label
      # tf.py_func wrapper of ``get_pairwise_inputs``
      image_dataset = image_dataset.map(
          lambda image_id: tuple(
              tf.py_func(
                  self.get_pairwise_inputs,
                  [image_id],
                  [
                      tf.int64,
                      tf.float32,
                      tf.float32,
                      tf.int32,
                      tf.int32,
                  ],
              )
          ),
          num_parallel_calls=4,
      )  # supported by tf 1.4?
      image_dataset = image_dataset.repeat()  # num_epochs can be param
      image_dataset = image_dataset.shuffle(
          buffer_size=self.batch_size * 20
      )
      image_dataset = image_dataset.batch(self.batch_size)
      self.iterator = image_dataset.make_initializable_iterator()
  
file_path: NiftyNet/niftynet/contrib/sampler_pairwise/sampler_pairwise_uniform_csv.py
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import tensorflow
  from niftynet.engine.image_window import ImageWindow
  from niftynet.layer.base_layer import Layer
  from niftynet.layer.grid_warper import AffineGridWarperLayer
  from niftynet.layer.resampler import ResamplerLayer
  from niftynet.layer.linear_resize import LinearResizeLayer
label_desc: Use image node_id 1 to create a new PairwiseUniformSampler object from inherited base classes: Layer with example: obj = PairwiseUniformSampler(reader_0, reader_1, data_param, batch_size)