def _get_reduce_out_dim(keep_dims, x_dim, x_ndim, batch_axis):
    """get out_dim for reduce* operation."""
    if keep_dims:
        out_dim = x_dim
    else:
        out_dim = 0
        for i in range(x_ndim):
            if i == x_dim:
                break
            if i in batch_axis:
                continue
            else:
                out_dim += 1
    return out_dim