def squeeze_singletons(item, to_squeeze):
    """ Squeeze singletons in item.

    This should be used with `normalize_index` like so:
    ```
    index, to_squeeze = normalize_index(index, data.shape)
    out = data[index]
    out = squeeze_singletons(out, to_squeeze)
    ```
    """
    if len(to_squeeze) == len(item.shape):
        return item.flatten()[0]
    elif to_squeeze:
        return item.squeeze(to_squeeze)
    else:
        return item