def METHOD_NAME(
    cls, op: DataFrameGroupByAgg, in_data: pd.DataFrame
) -> Union[pd.DataFrame, pd.Series]:
    groupby_params = op.groupby_params.copy()
    cols = in_data.index.name or in_data.index.names
    by = op.raw_groupby_params["by"]
    if by is not None:
        if op.output_types[0] == OutputType.dataframe:
            groupby_params.pop("level", None)
            groupby_params["by"] = cols
            in_data = in_data.reset_index()
    else:
        # When group by multi levels, we must get the actual all levels from raw_groupby_params,
        # since level field in op.groupby_params is not correct.
        groupby_params["level"] = op.raw_groupby_params["level"]
    res = in_data.groupby(**groupby_params).nunique()
    return res