from typing import List
import math


def count_epochs(
    len_input: int, len_output: int, len_dataset: int, stop_criterion_decibels: float, neurons: List[int]
) -> int:
    """
    Calculates the number of epoch for training
    len_dataset : int - training sample size
    len_output : int - number of neurons in the output layer
    len_input : int - number of input parameters
    stop_criterion_decibels : float - stopping criterion in decibels
    neurons : list, tuple - distribution of neurons to hidden layers
    """

    if stop_criterion_decibels > 0:
        raise ValueError("stop_criterion_decibels must be negative")

    s_value = len_dataset * math.sqrt(-0.5 * stop_criterion_decibels)
    weight_connections = (len_input + 1) * neurons[0]
    for i in range(len(neurons) - 1):
        weight_connections += (neurons[i] + 1) * neurons[i + 1]
    weight_connections += (neurons[-1] + 1) * len_output
    wieght_norm = weight_connections / (len_input * len_output)
    num_layers = sum(neurons) + len_output + len(neurons) + 1
    num_weight_coeff = weight_connections / num_layers
    s_value_all = s_value / (wieght_norm * num_weight_coeff) ** (1 / 4)
    s_value_all += s_value_all * 0.1
    return math.ceil(s_value_all)