def METHOD_NAME(y, num_samples, num_neg_samples: int):
    B, W, C = y.shape
    y = y.view(-1, C)  # BTC => (BxT)C
    with torch.no_grad():
        tszs = (buffered_arange(num_samples).unsqueeze(-1).expand(-1, num_neg_samples).flatten())
        neg_idxs = torch.randint(low=0, high=W - 1, size=(B, num_neg_samples * num_samples))
        neg_idxs[neg_idxs >= tszs] += 1
    for i in range(1, B):
        neg_idxs[i] += i * W
    negs = y[neg_idxs.view(-1)]
    negs = negs.view(B, num_samples, num_neg_samples, C).permute(2, 0, 1, 3)  # to NxBxTxC
    return negs