code: def get_timestep_embedding(timesteps, embedding_dim):
      """
      This matches the implementation in Denoising Diffusion Probabilistic Models:
      From Fairseq.
      Build sinusoidal embeddings.
      This matches the implementation in tensor2tensor, but differs slightly
      from the description in Section 3.5 of "Attention Is All You Need".
      """
      assert len(timesteps.shape) == 1
  
      half_dim = embedding_dim // 2
      emb = math.log(10000) / (half_dim - 1)
      emb = torch.exp(
          torch.arange(half_dim, dtype=torch.float32) * -emb
      )
      emb = emb.to(device=timesteps.device)
      emb = timesteps.float()[:, None] * emb[None, :]
      emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1)
      if embedding_dim % 2 == 1:  # zero pad
          emb = torch.nn.functional.pad(emb, (0, 1, 0, 0))
      return emb
  
imports: import logging
  import math
  from typing import Any, Callable, Optional
  import numpy
  import torch
  import torch.nn
  from einops import rearrange
  from packaging import version
  from ...modules.attention import LinearAttention, MemoryEfficientCrossAttention
label_desc: Use image node_id 1 for calling a global function with example usage: get_timestep_embedding(timesteps, embedding_dim) and returns: emb