class_docstr: This module learns positional embeddings up to a fixed maximum size.
class_docstr_tok: ["This","module","learns","positional","embeddings","up","to","a","fixed","maximum","size","."]
code: def make_positions(self, tensor, step):
      mask = tensor.ne(self.padding_id).int()
      positions = (
          torch.cumsum(mask, dim=1).type_as(mask)
          - 1
          + step
          + self.offset
      )
      return (positions * mask).long()
  
imports: import math
  import uuid
  from typing import Dict, Optional, List
  import torch
  from torch import Tensor, nn
  from torch.nn import Parameter, LayerNorm, Dropout
  from lightseq.training.ops.pytorch import util
  from lightseq.training.ops.pytorch.layer_base import TransformerEmbeddingLayerBase, TransformerEncoderLayerBase, TransformerDecoderLayerBase
  from .quantization import QuantLinear, TensorQuantizer, act_quant_config, weight_quant_config, out_quant_config, emb_quant_config
label_desc: Use image node_id 2 for calling the TrainablePositionalEmbedding obj's underlying member method code with example usage: obj.make_positions(tensor, step) and returns: unknown