<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_matplotlib_fontsize(matplotlib: ModuleType, fontsize: Union[int, float] = 12) -> None: """ Sets the current font size within the ``matplotlib`` library. **WARNING:** not an appropriate method for multithreaded environments, as it writes (indirectly) to ``matplotlib`` global objects. See CamCOPS for alternative methods. """

    font = {
        # http://stackoverflow.com/questions/3899980
        # http://matplotlib.org/users/customizing.html
        'family': 'sans-serif',
        # ... serif, sans-serif, cursive, fantasy, monospace
        'style': 'normal',  # normal (roman), italic, oblique
        'variant': 'normal',  # normal, small-caps
        'weight': 'normal',
        # ... normal [=400], bold [=700], bolder [relative to current],
        # lighter [relative], 100, 200, 300, ..., 900
        'size': fontsize  # in pt (default 12)
    }
    # noinspection PyUnresolvedReferences
    matplotlib.rc('font', **font)
    legend = {
        # http://stackoverflow.com/questions/7125009
        'fontsize': fontsize
    }
    # noinspection PyUnresolvedReferences
    matplotlib.rc('legend', **legend)