code: def noise_scheduler(
      sched_type: str,
      timesteps: int,
      min_beta: float = 0.0,
      max_beta: float = 0.01,
      s: float = 0.008,
  ) -> torch.Tensor:
      """Noise Scheduler.
  
      Args:
          sched_type (str): type of scheduler.
          timesteps (int): numbern of time steps.
          min_beta (float, optional): Minimum beta. Defaults to 0.0.
          max_beta (float, optional): Maximum beta. Defaults to 0.01.
          s (float, optional): Scheduler intersection. Defaults to 0.008.
  
      Returns:
          tensor: Noise.
  
      """
      if sched_type == "linear":
          scheduler = np.linspace(1e-6, 0.01, timesteps)
  
      elif sched_type == "cosine":
          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])
          scheduler = np.clip(betas, a_min=0, a_max=0.999)
  
      elif sched_type == "vpsde":
          scheduler = np.array(
              [
                  _vpsde_beta_t(t, timesteps, min_beta, max_beta)
                  for t in range(1, timesteps + 1)
              ]
          )
      else:
          raise NotImplementedError
  
      return torch.as_tensor(scheduler.astype(np.float32))
  
imports: import math
  from typing import Optional, Union
  import numpy
  import torch
  from torch import nn
  from torch.nn import functional
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
label_desc: Use image node_id 2 for calling a global function with example usage: noise_scheduler(sched_type, timesteps, min_beta, max_beta, s) and returns: torch