def maxdists(Z):
Z = np.asarray(Z, order='<STR_LIT:c>', dtype=np.double)<EOL>is_valid_linkage(Z, throw=True, name='<STR_LIT>')<EOL>n = Z.shape[<NUM_LIT:0>] + <NUM_LIT:1><EOL>MD = np.zeros((n - <NUM_LIT:1>,))<EOL>[Z] = _copy_arrays_if_base_present([Z])<EOL>_hierarchy.get_max_dist_for_each_cluster(Z, MD, int(n))<EOL>return MD<EOL>
Returns the maximum distance between any non-singleton cluster.

Parameters
----------
Z : ndarray
    The hierarchical clustering encoded as a matrix. See
    ``linkage`` for more information.

Returns
-------
maxdists : ndarray
    A ``(n-1)`` sized numpy array of doubles; ``MD[i]`` represents
    the maximum distance between any cluster (including
    singletons) below and including the node with index i. More
    specifically, ``MD[i] = Z[Q(i)-n, 2].max()`` where ``Q(i)`` is the
    set of all node indices below and including node i.