class_docstr: Just the engineered features from InfinitePositionalEncoding.
class_docstr_tok: ["Just","the","engineered","features","from","InfinitePositionalEncoding","."]
code: def forward(self, inputs):
      state = self.state
      depth = inputs.shape[-1]
  
      if self._mode == "predict":
          emb = self._get_embeddings(t=state)
          emb = emb[:, jnp.newaxis, :]
          state = state + 1
      else:
          input_len = inputs.shape[-2]
          emb = self._get_embeddings(
              t=jnp.arange(input_len, dtype=jnp.int32)
          )
          # Leave batch axis as 1 for broadcasting:
          emb = emb[jnp.newaxis, :, :]
          emb = jnp.broadcast_to(emb, inputs.shape[:-1] + (3,))
  
      # Replace the last num_features channels of input.
      inputs = jnp.concatenate(
          [inputs[..., : -self.num_features], emb], -1
      )
      if inputs.shape[-1] > depth:
          logging.warning(
              "dropping feature(s): %d down to %d",
              inputs.shape[-1],
              depth,
          )
          inputs = inputs[..., -depth:]
  
      assert inputs.shape[-1] == depth, inputs.shape
      self.state = state
      return inputs
  
imports: import logging
  import jax
  import jax.extend
  import numpy
  import trax
  from trax import fastmath
  from trax.fastmath import numpy
  from trax.layers import base
  from trax.layers import initializers
label_desc: Use image node_id 3 for calling the TimeBinPositionalEncoding obj's underlying member method code with example usage: obj.forward(inputs) and returns: inputs