#!/usr/bin/env python3
# Source: t6-practitioner-toolkit.html
import os, random
import numpy as np
import torch

def set_seed(seed: int = 42):
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)
    # Set PYTHONHASHSEED before starting Python. Changing it here is too late.
    # Request deterministic kernels. Reproducibility still depends on the full environment.
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False
    torch.use_deterministic_algorithms(True)
