from __future__ import annotations import numpy as np import torch def multiscale_batch(batch: int, length: int, seed: int) -> torch.Tensor: rng = np.random.default_rng(seed) time = np.arange(length, dtype=np.float32)[None] values = np.zeros((batch, length), dtype=np.float32) for low, high, scale in [(6, 12, 0.45), (20, 40, 0.35), (70, 110, 0.55)]: periods = rng.uniform(low, high, size=(batch, 1)) phases = rng.uniform(0, 2 * np.pi, size=(batch, 1)) amplitudes = rng.uniform(0.5, 1.0, size=(batch, 1)) * scale values += amplitudes * np.sin(2 * np.pi * time / periods + phases) values += rng.normal(0, 0.015, size=values.shape) return torch.from_numpy(values).float().unsqueeze(2)