class_docstr: This module learns positional embeddings up to a fixed maximum size.
class_docstr_tok: ["This","module","learns","positional","embeddings","up","to","a","fixed","maximum","size","."]
code: def __init__(self, num_embeddings: int, embedding_dim: int):
      # TrOCR is set up so that if padding_idx is specified then offset the embedding ids by 2
      # and adjust num_embeddings appropriately. Other models don't have this hack
      self.offset = 2
      super().__init__(num_embeddings + self.offset, embedding_dim)
  
imports: import copy
  import math
  from typing import Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_attn_mask_utils import _prepare_4d_attention_mask, _prepare_4d_causal_attention_mask
  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 1 to create a new TrOCRLearnedPositionalEmbedding object from inherited base classes: nn with example: obj = TrOCRLearnedPositionalEmbedding(num_embeddings, embedding_dim)