import torch


def tensor_std(t, eps=1e-8):
    """Compute standard deviation, output 1 if std < eps for stability (disabled features)."""
    s = t.std(0, keepdim=True)
    s = torch.where(s < eps, torch.ones_like(s), s)
    return s