<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def degrees_of_freedom(model):
 """ Return the degrees of freedom, i.e., number of "free variables". Parameters model : cobra.Model The metabolic model under investigation. Notes ----- This specifically refers to the dimensionality of the (right) null space of the stoichiometric matrix, as dim(Null(S)) corresponds directly to the number of free variables in the system [1]_. The formula used calculates this using the rank-nullity theorem [2]_. References .. [1] Fukuda, K. & Terlaky, T. Criss-cross methods: A fresh view on pivot algorithms. Mathematical Programming 79, 369-395 (1997). .. [2] Alama, J. The Rank+Nullity Theorem. Formalized Mathematics 15, (2007). """

    s_matrix, _, _ = con_helpers.stoichiometry_matrix(
        model.metabolites, model.reactions
    )
    return s_matrix.shape[1] - matrix_rank(model)