code: def get_timestep_embedding(
      timesteps,
      embedding_dim,
      flip_sin_to_cos=False,
      downscale_freq_shift=1,
      scale=1,
      max_period=10000,
  ):
      """
      This matches the implementation in Denoising Diffusion Probabilistic Models: Create sinusoidal timestep embeddings.
  
      :param timesteps: a 1-D Tensor of N indices, one per batch element.
                        These may be fractional.
      :param embedding_dim: the dimension of the output. :param max_period: controls the minimum frequency of the
      embeddings. :return: an [N x dim] Tensor of positional embeddings.
      """
      assert len(timesteps.shape) == 1, "Timesteps should be a 1d-array"
  
      half_dim = embedding_dim // 2
      exponent = -math.log(max_period) * paddle.arange(
          start=0, end=half_dim, dtype="float32"
      )
      exponent = exponent / (half_dim - downscale_freq_shift)
  
      emb = paddle.exp(exponent)
      emb = timesteps[:, None].astype("float32") * emb[None, :]
  
      # scale embeddings
      emb = scale * emb
  
      # concat sine and cosine embeddings
      emb = paddle.concat([paddle.sin(emb), paddle.cos(emb)], axis=-1)
  
      # flip sine and cosine embeddings
      if flip_sin_to_cos:
          emb = paddle.concat(
              [emb[:, half_dim:], emb[:, :half_dim]], axis=-1
          )
  
      # zero pad
      if embedding_dim % 2 == 1:
          emb = paddle.concat(
              emb, paddle.zeros([emb.shape[0], 1]), axis=-1
          )
      return emb
  
file_path: PaddleHub/modules/image/text_to_image/stable_diffusion_img2img/diffusers/models/embeddings.py
imports: import math
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: get_timestep_embedding(timesteps, embedding_dim, flip_sin_to_cos, downscale_freq_shift, scale, max_period) and returns: emb