class_docstr: This module produces sinusoidal positional embeddings of any length.
code: def __init__(
      self,
      num_positions: int,
      embedding_dim: int,
      padding_idx: Optional[int] = None,
  ):
      super().__init__()
      self.offset = 2
      self.embedding_dim = embedding_dim
      self.padding_idx = padding_idx
      self.weights = self.get_embedding(
          num_positions, embedding_dim, padding_idx
      )
      self.register_buffer("_float_tensor", torch.FloatTensor(1))
  
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 1 to create a new TrOCRSinusoidalPositionalEmbedding object from inherited base classes: nn with example: obj = TrOCRSinusoidalPositionalEmbedding(num_positions, embedding_dim, padding_idx)