class_docstr: Learned poisitional encoding
class_docstr_tok: ["Learned","poisitional","encoding"]
docstr: Adds positional encodings to an input
  
  Args:
      x: tensor to which the positional encodings will be added,
          expected shape is [B, seq_len, hidden_dim]
  
  Returns:
      the input tensor with the positional encodings added.
docstr_tok: ["Adds","positional","encodings","to","an","input","Args",":","x",":","tensor","to","which","the","positional","encodings","will","be","added",",","expected","shape","is","[","B",",","seq_len",",","hidden_dim","]","Returns",":","the","input","tensor","with","the","positional","encodings","added","."]
code: def forward(self, x: Tensor) -> Tensor:
      """Adds positional encodings to an input
  
      Args:
          x: tensor to which the positional encodings will be added,
              expected shape is [B, seq_len, hidden_dim]
  
      Returns:
          the input tensor with the positional encodings added.
      """
      assert x.dim() == 3 and x.shape[1:] == torch.Size(
          [self._seq_len, self._hidden_dim]
      ), f"Expected [B, seq_length, hidden_dim] got {x.shape}"
      return x + self._emb
  
imports: from functools import partial
  from typing import Callable, Optional
  import torch
  import torch.nn
  from torch import Tensor
  from .layers_utils import MLP, StochasticDepth, WindowMultiHeadAttention
label_desc: Use image node_id 2 for calling the LearnedPosition obj's underlying member method code with example usage: obj.forward(x) and returns: unknown