human
I wrote the below code

    input = numpy.asanyarray(input)
    find_positions = (find_min_positions or find_max_positions)
    positions = None
    if find_positions:
        positions = numpy.arange(input.size).reshape(input.shape)
    def single_group(vals, positions):
        result = []
        if find_min:
            result += [vals.min()]
        if find_min_positions:
            result += [positions[(vals == vals.min())][0]]
        if find_max:
            result += [vals.max()]
        if find_max_positions:
            result += [positions[(vals == vals.max())][0]]
        if find_median:
            result += [numpy.median(vals)]
        return result
    if (labels is None):
        return single_group(input, positions)
    (input, labels) = numpy.broadcast_arrays(input, labels)
    if (index is None):
        mask = (labels > 0)
        masked_positions = None
        if find_positions:
            masked_positions = positions[mask]
        return single_group(input[mask], masked_positions)
    if numpy.isscalar(index):
        mask = (labels == index)
        masked_positions = None
        if find_positions:
            masked_positions = positions[mask]
        return single_group(input[mask], masked_positions)
    if ((not _safely_castable_to_int(labels.dtype)) or (labels.min() < 0) or (labels.max() > labels.size)):
        (unique_labels, labels) = numpy.unique(labels, return_inverse=True)
        idxs = numpy.searchsorted(unique_labels, index)
        idxs[(idxs >= unique_labels.size)] = 0
        found = (unique_labels[idxs] == index)
    else:
        idxs = numpy.asanyarray(index, numpy.int).copy()
        found = ((idxs >= 0) & (idxs <= labels.max()))
    idxs[(~ found)] = (labels.max() + 1)
    if find_median:
        order = numpy.lexsort((input.ravel(), labels.ravel()))
    else:
        order = input.ravel().argsort()
    input = input.ravel()[order]
    labels = labels.ravel()[order]
    if find_positions:
        positions = positions.ravel()[order]
    result = []
    if find_min:
        mins =...

What's a good function header?
assistant
#Here's a good function header.

def _select(input, labels=None, index=None, find_min=False, find_max=False, find_min_positions=False, find_max_positions=False, find_median=False):