code: def cosine_beta_schedule(timesteps, s=0.008):
      """
      cosine schedule
      as proposed in https://openreview.net/forum?id=-NEXDKk8gZ
      """
      steps = timesteps + 1
      x = np.linspace(0, steps, steps)
      alphas_cumprod = (
          np.cos(((x / steps) + s) / (1 + s) * np.pi * 0.5) ** 2
      )
      alphas_cumprod = alphas_cumprod / alphas_cumprod[0]
      betas = 1 - (alphas_cumprod[1:] / alphas_cumprod[:-1])
      return np.clip(betas, a_min=0, a_max=0.999)
  
imports: from functools import partial
  from inspect import isfunction
  import numpy
  import torch
  from torch import nn, einsum
  import torch.nn.functional
label_desc: Use image node_id 4 for calling a global function with example usage: cosine_beta_schedule(timesteps, s) and returns: np