def retrieve_longest_smiles_from_optimal_model(task):
    """
    From the optimal models that were trained on the full data set using `full_working_optimal.py`,
    we retrieve the longest SMILES that was generated.

    Parameters
    ----------
    task : str
        The task to consider.

    Returns
    -------
    int :
        The longest SMILES that was generated when training the best model strategy for `task` data.

    """
    if task == "FreeSolv":
        longest_smiles = 76

    elif task == "ESOL":
        longest_smiles = 109

    elif task in ["lipo", "lipophilicity"]:
        longest_smiles = 268

    elif task in ["chembl28", "affinity"]:
        longest_smiles = 246
    else:
        longest_smiles = None

    return longest_smiles