<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def commuting_sets_by_zbasis(pauli_sums):
 """ Computes commuting sets based on terms having the same diagonal basis Following the technique outlined in the appendix of arXiv:1704.05018. :param pauli_sums: PauliSum object to group :return: dictionary where key value pair is a tuple corresponding to the basis and a list of PauliTerms associated with that basis. """

    diagonal_sets = {}
    for term in pauli_sums:
        diagonal_sets = _max_key_overlap(term, diagonal_sets)

    return diagonal_sets