class_docstr: ## U-Net model
docstr: ## Create sinusoidal time step embeddings
  
  :param time_steps: are the time steps of shape `[batch_size]`
  :param max_period: controls the minimum frequency of the embeddings.
docstr_tok: ["#","#","Create","sinusoidal","time","step","embeddings",":","param","time_steps",":","are","the","time","steps","of","shape","`","[","batch_size","]","`",":","param","max_period",":","controls","the","minimum","frequency","of","the","embeddings","."]
code: def time_step_embedding(
      self, time_steps: torch.Tensor, max_period: int = 10000
  ):
      """
      ## Create sinusoidal time step embeddings
  
      :param time_steps: are the time steps of shape `[batch_size]`
      :param max_period: controls the minimum frequency of the embeddings.
      """
      # $\frac{c}{2}$; half the channels are sin and the other half is cos,
      half = self.channels // 2
      # $\frac{1}{10000^{\frac{2i}{c}}}$
      frequencies = torch.exp(
          -math.log(max_period)
          * torch.arange(start=0, end=half, dtype=torch.float32)
          / half
      ).to(device=time_steps.device)
      # $\frac{t}{10000^{\frac{2i}{c}}}$
      args = time_steps[:, None].float() * frequencies[None]
      # $\cos\Bigg(\frac{t}{10000^{\frac{2i}{c}}}\Bigg)$ and $\sin\Bigg(\frac{t}{10000^{\frac{2i}{c}}}\Bigg)$
      return torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
  
imports: import math
  from typing import List
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from labml_nn.diffusion.stable_diffusion.model.unet_attention import SpatialTransformer
label_desc: Use image node_id 2 for calling the UNetModel obj's underlying member method code with example usage: obj.time_step_embedding(time_steps, max_period) and returns: torch