class_docstr: Creates learned positional embeddings for inputs.
  
  Attributes:
    inputs_shape: Shape of the 2D input, before flattening.
    hidden_dim: hidden dimension for the pos embeddings.
    max_h_w: Maximum height and width for the transformer inputs.
    posemb_init: Positional embeddings initializer.
    dtype: The dtype of the computation (default: float32).
class_docstr_tok: ["Creates","learned","positional","embeddings","for","inputs",".","Attributes",":","inputs_shape",":","Shape","of","the","2D","input",",","before","flattening",".","hidden_dim",":","hidden","dimension","for","the","pos","embeddings",".","max_h_w",":","Maximum","height","and","width","for","the","transformer","inputs",".","posemb_init",":","Positional","embeddings","initializer",".","dtype",":","The","dtype","of","the","computation","(","default",":","float32",")","."]
docstr: Creates the positional embeddings for transformer inputs.
  
  Returns:
    Positional embedding for inputs and queries.
code: def __call__(self) -> jnp.ndarray:
      """Creates the positional embeddings for transformer inputs.
  
      Returns:
        Positional embedding for inputs and queries.
      """
      _, h, w, c = self.inputs_shape
      max_h_w = self.max_h_w or np.max((h, w))
      assert h <= max_h_w and w <= max_h_w
  
      hidden_dim = self.hidden_dim or c
  
      row_pos_embed = self.param(
          "row_pos_embed", self.posemb_init, (max_h_w, hidden_dim // 2)
      )
      col_pos_embed = self.param(
          "col_pos_embed", self.posemb_init, (max_h_w, hidden_dim // 2)
      )
  
      # to `[h, w, hidden_dim//2]`
      x_pos_emb = jnp.tile(
          jnp.expand_dims(col_pos_embed[:w], axis=0), (h, 1, 1)
      )
      # to `[h, w, hidden_dim//2]`
      y_pos_emb = jnp.tile(
          jnp.expand_dims(row_pos_embed[:h], axis=1), (1, w, 1)
      )
      # to `[1, h*w, hidden_dim]`
      pos = jnp.expand_dims(
          jnp.concatenate((x_pos_emb, y_pos_emb), axis=-1).reshape(
              (h * w, hidden_dim)
          ),
          axis=0,
      )
  
      return jnp.asarray(pos, self.dtype)
  
imports: import functools
  from typing import Any, Callable, Dict, Tuple, Optional
  import flax.linen
  import jax
  from jax.nn import initializers
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.layers import attention_layers
  from scenic.projects.baselines import resnet
  from scenic.projects.baselines.detr import detr_base_model
label_desc: Use image node_id 1 for calling the InputPosEmbeddingLearned obj's underlying member method code with example usage: obj.__call__() and returns: jnp