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 forward(
      self, input_ids: torch.Tensor, past_key_values_length: int = 0
  ):
      bsz, seq_len = input_ids.size()
      # Create the position ids from the input token ids. Any padded tokens remain padded.
      position_ids = self.create_position_ids_from_input_ids(
          input_ids, self.padding_idx, past_key_values_length
      ).to(input_ids.device)
  
      # expand embeddings if needed
      max_pos = self.padding_idx + 1 + seq_len
      if max_pos > self.weights.size(0):
          self.make_weights(
              max_pos + self.offset,
              self.embedding_dim,
              self.padding_idx,
          )
  
      return (
          self.weights.index_select(0, position_ids.view(-1))
          .view(bsz, seq_len, -1)
          .detach()
      )
  
imports: 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 BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_speech_to_text import Speech2TextConfig
label_desc: Use image node_id 4 for calling the Speech2TextSinusoidalPositionalEmbedding obj's underlying member method code with example usage: obj.forward(input_ids, past_key_values_length) and returns: self