def latex_name(model_name):
    """
    Replaces model names with latex-friendly names.

    E.g. "avg_br" becomes "$E_{avg}|D_{br}$".

    Args:
        model_name (str): original name of the model

    Returns:
        latex_name (str): latex-friendly translation of the model name
    """
    if model_name == "enc_dec":
        return "$seq2seq$"
    elif "enc_dec_" in model_name:
        return "$seq2seq_{{{}}}$".format(model_name[len("enc_dec_"):])
    elif "_" not in model_name:
        return model_name

    i = model_name.index("_")

    return "$E_{{{}}}|D_{{{}}}$".format(model_name[:i], model_name[i+1:])