class_docstr: Unit test for NiftyregImageResamplingLayer
class_docstr_tok: ["Unit","test","for","NiftyregImageResamplingLayer"]
code: def _test_resampling(self, use_gpu):
      for floating in self._get_images():
          floating_data = floating.get_data()
          nof_dims = len(floating_data.shape)
  
          floating_shape = list(floating_data.shape)
          if floating_shape[-1] == 1:
              floating_shape = floating_shape[:-1]
          image_batch_shape = [1] + floating_shape + [1]
          disp_batch_shape = [1] + floating_shape + [nof_dims]
  
          for code, inter in self.INTERPOLATIONS:
              with self.session(use_gpu=use_gpu) as sess:
                  img = tf.placeholder(
                      tf.float32, shape=image_batch_shape
                  )
                  disp = tf.placeholder(
                      tf.float32, shape=disp_batch_shape
                  )
  
                  warped = NiftyregImageResamplingLayer(
                      interpolation=inter, boundary="NAN"
                  )
                  warped = warped(img, disp)
  
                  for u in (0.5001, 3.50001):
                      for d in range(nof_dims):
                          displacement_data = (
                              self._make_constant_displacement_image(
                                  u, d, floating_data
                              )
                          )
  
                          resampled_data = sess.run(
                              warped,
                              feed_dict={
                                  img: floating_data.reshape(
                                      image_batch_shape
                                  ),
                                  disp: displacement_data.reshape(
                                      disp_batch_shape
                                  ),
                              },
                          )
  
                          resampled_data = resampled_data.reshape(
                              floating_shape
                          )
  
                          self._test_resampled(
                              resampled_data, floating_data, u, code, d
                          )
  
file_path: NiftyNet/niftynet/contrib/niftyreg_image_resampling/tests/test_python_wrapper.py
imports: from niftynet.contrib.niftyreg_image_resampling.niftyreg_image_resampling import NiftyregImageResamplingLayer
  from niftynet.contrib.niftyreg_image_resampling.tests.test_resampler import ResamplerTest
  import numpy
  import tensorflow
  import tensorflow.test
label_desc: Use image node_id 5 for calling the WrapperResamplerTest obj's underlying member method code with example usage: obj._test_resampling(use_gpu) without return types