code: def layer_op(self):
      (
          image_id,
          fixed_inputs,
          moving_inputs,
          fixed_shape,
          moving_shape,
      ) = self.iterator.get_next()
      # TODO preprocessing layer modifying
      #      image shapes will not be supported
      # assuming the same shape across modalities, using the first
      image_id.set_shape((self.batch_size,))
      image_id = tf.to_float(image_id)
  
      fixed_inputs.set_shape(
          (self.batch_size,) + (None,) * self.spatial_rank + (2,)
      )
      # last dim is 1 image + 1 label
      moving_inputs.set_shape(
          (self.batch_size,) + self.moving_image_shape + (2,)
      )
      fixed_shape.set_shape((self.batch_size, self.spatial_rank + 1))
      moving_shape.set_shape((self.batch_size, self.spatial_rank + 1))
  
      # resizing the moving_inputs to match the target
      # assumes the same shape across the batch
      target_spatial_shape = tf.unstack(fixed_shape[0], axis=0)[
          : self.spatial_rank
      ]
      moving_inputs = Resize(new_size=target_spatial_shape)(
          moving_inputs
      )
      combined_volume = tf.concat(
          [fixed_inputs, moving_inputs], axis=-1
      )
  
      # TODO affine data augmentation here
      if self.spatial_rank == 3:
          window_channels = (
              np.prod(self.window_size[self.spatial_rank :]) * 4
          )
          # TODO if no affine augmentation:
          img_spatial_shape = target_spatial_shape
          win_spatial_shape = [
              tf.constant(dim)
              for dim in self.window_size[: self.spatial_rank]
          ]
  
          # scale the image to new space
          batch_scale = [
              tf.reshape(tf.to_float(img) / tf.to_float(win), (1, 1))
              for (win, img) in zip(
                  win_spatial_shape, img_spatial_shape
              )
          ]
          batch_scale = tf.concat(batch_scale, axis=1)
          affine_constraints = (
              (None, 0.0, 0.0, 0.0),
              (0.0, None, 0.0, 0.0),
              (0.0, 0.0, None, 0.0),
          )
          computed_grid = AffineGridWarperLayer(
              source_shape=(None, None, None),
              output_shape=self.window_size[: self.spatial_rank],
              constraints=affine_constraints,
          )(batch_scale)
          computed_grid.set_shape(
              (1,)
              + self.window_size[: self.spatial_rank]
              + (self.spatial_rank,)
          )
          resampler = ResamplerLayer(
              interpolation="linear", boundary="replicate"
          )
          windows = resampler(combined_volume, computed_grid)
          out_shape = (
              [self.batch_size]
              + list(self.window_size[: self.spatial_rank])
              + [window_channels]
          )
          windows.set_shape(out_shape)
  
          image_id = tf.reshape(image_id, (self.batch_size, 1))
          start_location = tf.zeros(
              (self.batch_size, self.spatial_rank)
          )
          end_location = tf.constant(
              self.window_size[: self.spatial_rank]
          )
          end_location = tf.reshape(
              end_location, (1, self.spatial_rank)
          )
          end_location = tf.to_float(
              tf.tile(end_location, [self.batch_size, 1])
          )
          locations = tf.concat(
              [image_id, start_location, end_location], axis=1
          )
      return windows, locations
  
file_path: NiftyNet/niftynet/contrib/sampler_pairwise/sampler_pairwise_resize_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 4 for calling the PairwiseResizeSampler obj's underlying member method code with example usage: obj.layer_op() and returns: windows,  locations