code: def get_sinusoidal_positional_embedding(length, embed_dim):
      half_dim = embed_dim // 2
      emb = math.log(10000) / (half_dim - 1)
      emb = torch.exp(torch.arange(half_dim, dtype=torch.float) * -emb)
      emb = torch.arange(length, dtype=torch.float).unsqueeze(
          1
      ) * emb.unsqueeze(0)
      emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1).view(
          length, -1
      )
      if embed_dim % 2 == 1:
          emb = torch.cat([emb, torch.zeros(length, 1)], dim=1)
      return emb
  
imports: import math
  from typing import Callable, Optional
  import torch
  from fairseq import utils
  from fairseq.modules import LayerDropModuleList, LayerNorm, PositionalEmbedding
  from fairseq.modules.fairseq_dropout import FairseqDropout
  from pytext.utils.usage import log_class_usage
  from torch import nn
  from torch.nn import Parameter
  from .None import LunarMultiheadAttention
label_desc: Use image node_id 2 for calling a global function with example usage: get_sinusoidal_positional_embedding(length, embed_dim) and returns: emb