def get_n_fit_scalars(hmm):
    """
    Function to compute the degrees of freedom of a HMM based on the parameters
    that are trained in it.

    :param hmm: a hidden Markov model (GaussianHMM, MultinomialHMM, etc)
    :type hmm: object
    :return: single numeric value representing the number of trainable
        parameters of the model
    :rtype: int

    """
    train_params = hmm.tr_params
    n_fit_scalars_per_param = hmm.get_n_fit_scalars_per_param()
    dof = 0
    for par in n_fit_scalars_per_param:
        if par in train_params:
            dof += n_fit_scalars_per_param[par]

    return dof