class_docstr: This module produces sinusoidal positional embeddings of any length.
  
  Padding symbols are ignored.
class_docstr_tok: ["This","module","produces","sinusoidal","positional","embeddings","of","any","length",".","Padding","symbols","are","ignored","."]
code: def __init__(
      self,
      embedding_dim,
      padding_idx,
      init_size=124,
      learned_embed=False,
  ):
      super().__init__()
      self.embedding_dim = embedding_dim
      self.padding_idx = padding_idx
      if not learned_embed:
          self.sinusoidal_embedding_dim = embedding_dim
          self.learned_embed = learned_embed
          self.learned_embedding = PlaceholderIdentity()
      else:
          assert embedding_dim % 2 == 0
          self.sinusoidal_embedding_dim = embedding_dim // 2
          self.learned_embedding = nn.Embedding(
              init_size, embedding_dim // 2, padding_idx
          )
          self.learned_embed = learned_embed
      self.weights = nn.Parameter(
          get_sinusoidal_embedding(
              init_size, self.sinusoidal_embedding_dim, padding_idx
          )
      )
      self.weights.requires_grad = False
      self.max_positions = int(1e5)
  
imports: import math
  from enum import Enum
  from typing import Dict, Optional
  import torch
  import torch.nn
  import torch.nn.functional
  from pytext.models.representations.transformer import PositionalEmbedding
  from pytext.models.seq_models.base import PlaceholderIdentity
  from torch import Tensor
  from .utils import make_positions
label_desc: Use image node_id 1 to create a new SinusoidalPositionalEmbedding object from inherited base classes: nn with example: obj = SinusoidalPositionalEmbedding(embedding_dim, padding_idx, init_size, learned_embed)