import ast


def count_class_defs(notebook):
    """
    The function takes a notebook returns the number of class definitions
        Extract the number of class definitions from a python code

        Args:
            notebook(Notebook): python object representing the notebook
        Returns:
            class_def_num: integer value representing the number of class definitions in the python code

        A way you might use me is

        class_def_count = count_class_defs(nb)
    """
    code = notebook.script
    tree = ast.parse(code)
    class_def_num = sum(isinstance(exp, ast.ClassDef) for exp in tree.body)
    return class_def_num