class_docstr: This module learns positional embeddings up to a fixed maximum size.
docstr: `input_ids' shape is expected to be [bsz x seqlen].
docstr_tok: ["`","input_ids","'","shape","is","expected","to","be","[","bsz","x","seqlen","]","."]
code: def forward(
      self, input_ids: torch.Tensor, past_key_values_length: int = 0
  ):
      """`input_ids' shape is expected to be [bsz x seqlen]."""
  
      bsz, seq_len = input_ids.shape[:2]
      positions = torch.arange(
          past_key_values_length,
          past_key_values_length + seq_len,
          dtype=torch.long,
          device=self.weight.device,
      ).expand(bsz, -1)
  
      return super().forward(positions + self.offset)
  
imports: import copy
  import math
  import random
  from typing import Optional, Tuple
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, logging, replace_return_docstrings
  from .configuration_trocr import TrOCRConfig
label_desc: Use image node_id 2 for calling the TrOCRLearnedPositionalEmbedding obj's underlying member method code with example usage: obj.forward(input_ids, past_key_values_length) and returns: super