class_docstr: Position encodings conform to the position encodings protocol.
class_docstr_tok: ["Position","encodings","conform","to","the","position","encodings","protocol","."]
code: def test_inference(self, n, t, c):
      # Get the eval mode outputs:
      encoding = self.Encoding(mode="eval")
      input_ntc = np.random.randn(n, t, c)
      rng = fastmath.random.get_prng(1234)
      encoding.init(input_ntc, rng=rng)
      output_ntc = encoding(input_ntc)
  
      is_random = self.Encoding == pe.InfinitePositionalEncoding
  
      # Get the predict mode outputs:
      encoding_pred = self.Encoding(mode="predict")
      encoding_pred.init(input_ntc[:, 0:1, :], rng=rng)
      output_ntc0 = encoding_pred(input_ntc[:, 0:1, :])
      if not is_random:
          np.testing.assert_allclose(
              output_ntc0, output_ntc[:, 0:1, :], atol=1e-4
          )
  
      output_ntc1 = encoding_pred(input_ntc[:, 1:2, :])
      if not is_random:
          np.testing.assert_allclose(
              output_ntc1, output_ntc[:, 1:2, :], atol=1e-4
          )
  
      output_ntc2 = encoding_pred(input_ntc[:, 2:3, :])
      if not is_random:
          np.testing.assert_allclose(
              output_ntc2, output_ntc[:, 2:3, :], atol=1e-4
          )
  
file_path: trax/trax/layers/research/position_encodings_test.py
imports: import functools
  import absl.testing.absltest
  import numpy
  import parameterized
  from trax import fastmath
  import trax.layers.research.position_encodings
label_desc: Use image node_id 2 for calling the PositionEncodingsTest obj's underlying member method code with example usage: obj.test_inference(n, t, c) without return types