@classmethod
def _from_setup(cls, json_dict, num_states, model_initial, model_transition,
    model_emissions, covariates_initial, covariates_transition,
    covariates_emissions, responses_emissions, trained):
    """
        Helper function to construct the IOHMM model used by from_json and from_config.
        Parameters
        ----------
        json_dict : the dictionary that specifies the model
        num_states: number of hidden states
        trained: a boolean indicating whether the models are already trained.
                 If the models are already trained, set the models directly,
                 otherwise initialize from empty linear models.
        if trained models, then the parameters are:
            model_initial: a linear model
            model_transitions: a list of linear models, one for each hidden state.
            model_emissions: a list of list of linear models,
                             the outer list is for each hidden state,
                             the inner list is for each emission model.
        otherwise:
            model_initial: the initial probability model (simply indicates its type)
            model_transition: the transition probability model (simply indicates its type)
            model_emissions: list of linear models, one for each emission.
        covariates_initial: list of strings,
                            each indicates the field name in the dataframe
                            to use as the independent variables.
        covariates_transition: list of strings,
                               each indicates the field name in the dataframe
                               to use as the independent variables.
        covariates_emissions: list of list of strings, each outer list is for one emission model
                              and each inner list of strings
                              indicates the field names in the dataframe
                              to use as the independent variables.
        responses_emissions: list of list of strings, each outer list is for one emission
                             and each inner list of strings
                             indicates the field names in the dataframe
                             to use as the dependent variables.
        Returns
        -------
        IOHMM object: an IOHMM object specified by the json_dict and other arguments
        """
    model = cls(num_states=num_states)
    model.set_models(model_initial=model_initial, model_transition=
        model_transition, model_emissions=model_emissions, trained=trained)
    model.set_inputs(covariates_initial=covariates_initial,
        covariates_transition=covariates_transition, covariates_emissions=
        covariates_emissions)
    model.set_outputs(responses_emissions=responses_emissions)
    return model
