<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_explanation(explanation, original_msg=None):
 """This formats an explanation Normally all embedded newlines are escaped, however there are three exceptions: \n{, \n} and \n~. The first two are intended cover nested explanations, see function and attribute explanations for examples (.visit_Call(), visit_Attribute()). The last one is for when one explanation needs to span multiple lines, e.g. when displaying diffs. """

    if not conf.is_message_introspection_enabled() and original_msg:
        return original_msg
    explanation = ecu(explanation)
    lines = _split_explanation(explanation)
    result = _format_lines(lines)
    return u('\n').join(result)