{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from stable_audio_tools.inference.sampling import get_alphas_sigmas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "diffusion_input = torch.ones((1, 128, 3000))\n",
    "infill = True\n",
    "\n",
    "noise = torch.randn_like(diffusion_input)\n",
    "print(noise)\n",
    "\n",
    "if infill:\n",
    "    # mask some of the noise with zeros\n",
    "    n_tokens_mask = 1000\n",
    "    mask = torch.zeros_like(noise)\n",
    "    mask[:, :, n_tokens_mask:] = 1\n",
    "    noise = noise * mask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(noise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "alphas, sigmas = get_alphas_sigmas(torch.tensor([0.5]))\n",
    "alphas = alphas[:, None, None]\n",
    "sigmas = sigmas[:, None, None]\n",
    "\n",
    "noised_inputs = diffusion_input * alphas + noise * sigmas\n",
    "targets = noise * alphas - diffusion_input * sigmas\n",
    "print(noised_inputs)\n",
    "print(targets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "suno_env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
