def test_four_dimensional_input_and_keepdims(self):
    x = rng.rand(2, 3, 4, 5)
    for axis in [None, 0, 1, -2, (0,), (-1,), (-1, 1), (3, 1), (-3, 0)]:
      expected_percentile = np.percentile(
          x,
          q=0.77,
          interpolation=self._interpolation,
          axis=axis,
          keepdims=True)
      with self.test_session():
        pct = sample_stats.percentile(
            x,
            q=0.77,
            interpolation=self._interpolation,
            axis=axis,
            keep_dims=True)
        self.assertAllEqual(expected_percentile.shape, pct.get_shape())
        self.assertAllClose(expected_percentile, pct.eval())