class_docstr: ### Embeddings for $t$
class_docstr_tok: ["#","#","#","Embeddings","for","$","t","$"]
code: def forward(self, t: torch.Tensor):
      # Create sinusoidal position embeddings
      # [same as those from the transformer](../../transformers/positional_encoding.html)
      #
      # \begin{align}
      # PE^{(1)}_{t,i} &= sin\Bigg(\frac{t}{10000^{\frac{i}{d - 1}}}\Bigg) \\
      # PE^{(2)}_{t,i} &= cos\Bigg(\frac{t}{10000^{\frac{i}{d - 1}}}\Bigg)
      # \end{align}
      #
      # where $d$ is `half_dim`
      half_dim = self.n_channels // 8
      emb = math.log(10_000) / (half_dim - 1)
      emb = torch.exp(torch.arange(half_dim, device=t.device) * -emb)
      emb = t[:, None] * emb[None, :]
      emb = torch.cat((emb.sin(), emb.cos()), dim=1)
  
      # Transform with the MLP
      emb = self.act(self.lin1(emb))
      emb = self.lin2(emb)
  
      #
      return emb
  
imports: import math
  from typing import Optional, Tuple, Union, List
  import torch
  from torch import nn
  from labml_helpers.module import Module
label_desc: Use image node_id 2 for calling the TimeEmbedding obj's underlying member method code with example usage: obj.forward(t) and returns: emb