class_docstr: 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.register_buffer("weights", emb_weights)
  
imports: import math
  import random
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  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_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_xglm import XGLMConfig
label_desc: Use image node_id 2 for calling the XGLMSinusoidalPositionalEmbedding obj's underlying member method code with example usage: obj.make_weights(num_embeddings, embedding_dim, padding_idx) without return types