class_docstr: Tests for utilities in nn_ops.py.
class_docstr_tok: ["Tests","for","utilities","in","nn_ops.py","."]
docstr: Tests upscale2x_nearest_neighbor.
docstr_tok: ["Tests","upscale2x_nearest_neighbor","."]
code: def test_central_crop(self):
      """Tests upscale2x_nearest_neighbor."""
      inputs = jnp.array(np.random.normal(size=(16, 32, 32, 128)))
  
      # check the case where the outputs should be same as the inputs
      outputs = nn_ops.central_crop(
          inputs, target_shape=(16, 32, 32, 128)
      )
      self.assertTrue(jnp.array_equal(outputs, inputs))
  
      # check the output shape
      outputs = nn_ops.central_crop(
          inputs, target_shape=(16, 6, 6, 128)
      )
      self.assertEqual(outputs.shape, (16, 6, 6, 128))
  
      inputs = jnp.arange(100.0).reshape((1, 10, 10, 1))
      target_shape = (1, 8, 8, 1)
      output = nn_ops.central_crop(inputs, target_shape)
      # check up-left and down-right pixel of the output
      self.assertEqual(output[0, 0, 0, 0], 11.0)
      self.assertEqual(output[0, -1, -1, 0], 88.0)
  
imports: import functools
  from absl.testing import absltest
  from absl.testing import parameterized
  import flax.linen
  import jax
  import jax.numpy
  import numpy
  from scenic.model_lib.layers import nn_ops
label_desc: Use image node_id 6 for calling the NNOpsTest obj's underlying member method code with example usage: obj.test_central_crop() without return types