class_docstr: This module produces sinusoidal positional embeddings of any length.
class_docstr_tok: ["This","module","produces","sinusoidal","positional","embeddings","of","any","length","."]
code: def make_weights(
      self,
      num_embeddings: int,
      embedding_dim: int,
      padding_idx: Optional[int] = None,
  ):
      emb_weights = self.get_embedding(
          num_embeddings, embedding_dim, padding_idx
      )
      if hasattr(self, "weights"):
          # in forward put the weights on the correct dtype and device of the param
          emb_weights = emb_weights.to(
              dtype=self.weights.dtype, device=self.weights.device
          )
  
      self.weights = nn.Parameter(emb_weights)
      self.weights.requires_grad = False
      self.weights.detach_()
  
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_speech_to_text_2 import Speech2Text2Config
label_desc: Use image node_id 2 for calling the Speech2Text2SinusoidalPositionalEmbedding obj's underlying member method code with example usage: obj.make_weights(num_embeddings, embedding_dim, padding_idx) without return types