class_docstr: This module learns positional embeddings up to a fixed maximum size.
docstr: `input_ids_shape` is expected to be [bsz x seqlen].
docstr_tok: ["`","input_ids_shape","`","is","expected","to","be","[","bsz","x","seqlen","]","."]
code: def forward(
      self,
      attention_mask: torch.LongTensor,
      past_key_values_length: int = 0,
  ):
      """`input_ids_shape` is expected to be [bsz x seqlen]."""
      attention_mask = attention_mask.long()
  
      # create positions depending on attention_mask
      positions = (
          torch.cumsum(attention_mask, dim=1).type_as(attention_mask)
          * attention_mask
      ).long() - 1
  
      # cut positions if `past_key_values_length` is > 0
      positions = positions[:, past_key_values_length:]
  
      return super().forward(positions + self.offset)
  
imports: import torch
  from deepspeed import comm
  from torch import nn
  from torch.nn import functional
  from torch.nn.parameter import Parameter
label_desc: Use image node_id 2 for calling the OPTEmbedding obj's underlying member method code with example usage: obj.forward(attention_mask, past_key_values_length) and returns: super