<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_format_module(image_format):
 """Get the format module to use for optimizing the image."""

    format_module = None
    nag_about_gifs = False

    if detect_format.is_format_selected(image_format,
                                        Settings.to_png_formats,
                                        png.PROGRAMS):
        format_module = png
    elif detect_format.is_format_selected(image_format, jpeg.FORMATS,
                                          jpeg.PROGRAMS):
        format_module = jpeg
    elif detect_format.is_format_selected(image_format, gif.FORMATS,
                                          gif.PROGRAMS):
        # this captures still GIFs too if not caught above
        format_module = gif
        nag_about_gifs = True

    return format_module, nag_about_gifs