"""Small helpers used across the training and evaluation code."""

import random

import numpy as np
import torch


def set_seed(seed: int = 42):
  """Make Python / NumPy / PyTorch / CUDA randomness reproducible."""
  random.seed(seed)
  np.random.seed(seed)
  torch.manual_seed(seed)
  if torch.cuda.is_available():
      torch.cuda.manual_seed_all(seed)


def format_seconds(s: float) -> str:
  """Pretty-print a duration in seconds as HH:MM:SS."""
  h = int(s // 3600)
  m = int((s % 3600) // 60)
  sec = int(s % 60)
  return f"{h:02d}:{m:02d}:{sec:02d}"