class_docstr: Uses sine & cosine to represent position
class_docstr_tok: ["Uses","sine","&","cosine","to","represent","position"]
code: def build_position(model_dim, max_len, device=None):
      position = torch.arange(max_len).unsqueeze(1)
      div_term = torch.exp(
          torch.arange(0, model_dim, 2)
          * (-math.log(10000.0) / model_dim)
      )
      pe = torch.zeros(max_len, model_dim)
      pe[:, 0::2] = torch.sin(position * div_term)
      pe[:, 1::2] = torch.cos(position * div_term)
      if device is not None:
          pe = pe.to(device=device)
      return pe
  
file_path: stanza/stanza/models/constituency/positional_encoding.py
imports: import math
  import torch
  from torch import nn
label_desc: Use image node_id 2 for calling the SinusoidalEncoding obj's underlying member method code with example usage: obj.build_position(model_dim, max_len, device) and returns: pe