<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mpl_linestyle2pgfplots_linestyle(line_style, line=None):
 """Translates a line style of matplotlib to the corresponding style in PGFPlots. """

    # linestyle is a string or dash tuple. Legal string values are
    # solid|dashed|dashdot|dotted.  The dash tuple is (offset, onoffseq) where onoffseq
    # is an even length tuple of on and off ink in points.
    #
    # solid: [(None, None), (None, None), ..., (None, None)]
    # dashed: (0, (6.0, 6.0))
    # dotted: (0, (1.0, 3.0))
    # dashdot: (0, (3.0, 5.0, 1.0, 5.0))
    if isinstance(line_style, tuple):
        if line_style[0] is None:
            return None

        if len(line_style[1]) == 2:
            return "dash pattern=on {}pt off {}pt".format(*line_style[1])

        assert len(line_style[1]) == 4
        return "dash pattern=on {}pt off {}pt on {}pt off {}pt".format(*line_style[1])

    if isinstance(line, mpl.lines.Line2D) and line.is_dashed():
        # see matplotlib.lines.Line2D.set_dashes

        # get defaults
        default_dashOffset, default_dashSeq = mpl.lines._get_dash_pattern(line_style)

        # get dash format of line under test
        dashSeq = line._us_dashSeq
        dashOffset = line._us_dashOffset

        lst = list()
        if dashSeq != default_dashSeq:
            # generate own dash sequence
            format_string = " ".join(len(dashSeq) // 2 * ["on {}pt off {}pt"])
            lst.append("dash pattern=" + format_string.format(*dashSeq))

        if dashOffset != default_dashOffset:
            lst.append("dash phase={}pt".format(dashOffset))

        if len(lst) > 0:
            return ", ".join(lst)

    return {
        "": None,
        "None": None,
        "none": None,  # happens when using plt.boxplot()
        "-": "solid",
        "solid": "solid",
        ":": "dotted",
        "--": "dashed",
        "-.": "dash pattern=on 1pt off 3pt on 3pt off 3pt",
    }[line_style]