class_docstr: This module produces sinusoidal positional embeddings of any length.
docstr: We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
  
  Args:
      inputs_embeds: torch.Tensor
  
  Returns: torch.Tensor
docstr_tok: ["We","are","provided","embeddings","directly",".","We","can","not","infer","which","are","padded","so","just","generate","sequential","position","ids",".","Args",":","inputs_embeds",":","torch.Tensor","Returns",":","torch.Tensor"]
code: def create_position_ids_from_inputs_embeds(
      self, inputs_embeds, past_key_values_length
  ):
      """
      We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
  
      Args:
          inputs_embeds: torch.Tensor
  
      Returns: torch.Tensor
      """
      input_shape = inputs_embeds.size()[:-1]
      sequence_length = input_shape[1]
  
      position_ids = torch.arange(
          self.padding_idx + 1,
          sequence_length + self.padding_idx + 1,
          dtype=torch.long,
          device=inputs_embeds.device,
      )
      return (
          position_ids.unsqueeze(0).expand(input_shape).contiguous()
          + past_key_values_length
      )
  
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 5 for calling the XGLMSinusoidalPositionalEmbedding obj's underlying member method code with example usage: obj.create_position_ids_from_inputs_embeds(inputs_embeds, past_key_values_length) and returns: unknown