docstr: Parameters
  ----------
  positions : th.Tensor
      Shape (..., )
  
  Returns
  -------
  ret :
      Shape (..., units)
docstr_tok: ["Parameters","--","--","--","--","--","positions",":","th.Tensor","Shape","(","...",",",")","Returns","--","--","--","-","ret",":","Shape","(","...",",","units",")"]
code: def forward(self, positions):
      """
  
      Parameters
      ----------
      positions : th.Tensor
          Shape (..., )
  
      Returns
      -------
      ret :
          Shape (..., units)
      """
      emb = positions.unsqueeze(-1) * self.freq
      sin_emb = th.sin(emb)
      cos_emb = th.cos(emb)
      if self._units % 2 == 0:
          return th.cat([sin_emb, cos_emb], dim=-1)
      else:
          return th.cat(
              [
                  sin_emb,
                  cos_emb,
                  th.zeros_like(positions).unsqueeze(-1),
              ],
              dim=-1,
          )
  
imports: import math
  from collections import OrderedDict
  import torch
  import numpy
  from torch import nn
  from typing import Union
  from .utils import to_torch_dtype
label_desc: Use image node_id 2 for calling the SinusoidalPositionalEmbedding obj's underlying member method code with example usage: obj.forward(positions) and returns: th, th