code: def compute_aggs(df, groups, aggs, idx_cols, group_col, dropna=True):
      all_code = []
      all_calculated_aggs = []
      all_calculated_cols = []
      for curr_agg, curr_agg_cols in aggs.items():
          chart_data_key = "chart_data_{}".format(curr_agg)
          if curr_agg in ["pctsum", "pctct"]:
              func = "sum" if curr_agg == "pctsum" else "size"
              subidx_cols = [
                  c for c in idx_cols if c not in make_list(group_col)
              ]
              calc_group = getattr(groups[curr_agg_cols], func)()
              calc_group = (
                  calc_group
                  / getattr(
                      pandas_util.groupby(
                          df, subidx_cols, dropna=dropna
                      )[curr_agg_cols],
                      func,
                  )()
                  * 100
              )
              if isinstance(calc_group, pd.Series):
                  calc_group.name = curr_agg_cols[0]
                  calc_group = calc_group.to_frame()
  
              if len(curr_agg_cols) > 1:
                  groups.columns = curr_agg_cols
              elif len(curr_agg_cols) == 1:
                  groups.name = curr_agg_cols[0]
              code = (
                  "{chart_data} = chart_data{groupby}[['{agg_cols}']].{agg}()\n"
                  "{chart_data} = {chart_data} / {chart_data}{subgroupby}.{agg}()"
              )
              code = code.format(
                  groupby=pandas_util.groupby_code(
                      idx_cols, dropna=dropna
                  ),
                  subgroupby=pandas_util.groupby_code(
                      subidx_cols, dropna=dropna
                  ),
                  agg_cols="', '".join(make_list(curr_agg_cols)),
                  agg=func,
                  chart_data=chart_data_key,
              )
              all_code.append(code)
          elif curr_agg in ["first", "last"]:
              agg_func = "head" if curr_agg == "first" else "tail"
  
              def _build_first_last():
                  for col in curr_agg_cols:
                      yield groups[[col]].apply(
                          lambda x: getattr(
                              x.sort_values(by=col, ascending=True),
                              agg_func,
                          )(1)
                      ).reset_index(-1, drop=True)
  
              calc_group = pd.concat(list(_build_first_last()), axis=1)
              all_code += [
                  (
                      "groups = chart_data{groupby}\n"
                      "\ndef _build_first_last():\n"
                      "\tfor col in ['{agg_cols}']:\n"
                      "\t\tyield groups[[col]].apply(\n"
                      "\t\t\tlambda x: x.sort_values(by=col, ascending=True).{agg_func}(1)\n"
                      "\t\t)\n\n"
                      "{chart_data} = pd.DataFrame(list(_build_first_last()), columns=['{agg_cols}'])"
                  ).format(
                      groupby=pandas_util.groupby_code(
                          idx_cols, dropna=dropna
                      ),
                      agg_cols="', '".join(curr_agg_cols),
                      agg_func=agg_func,
                      chart_data=chart_data_key,
                  )
              ]
          else:
              calc_group = getattr(groups[curr_agg_cols], curr_agg)()
              all_code += [
                  "{chart_data} = chart_data{groupby}[['{agg_cols}']].{agg}()".format(
                      groupby=pandas_util.groupby_code(
                          idx_cols, dropna=dropna
                      ),
                      agg_cols="', '".join(curr_agg_cols),
                      agg=curr_agg,
                      chart_data=chart_data_key,
                  )
              ]
          final_cols = [
              "{}{}{}".format(col, CHART_JOINER_CHAR, curr_agg)
              for col in calc_group.columns
          ]
          all_code.append(
              "{chart_data}.columns = ['{cols}']".format(
                  chart_data=chart_data_key, cols="','".join(final_cols)
              )
          )
          calc_group.columns = final_cols
          all_calculated_aggs.append(calc_group)
          all_calculated_cols += final_cols
  
      if len(all_calculated_aggs) > 1:
          all_code.append(
              "chart_data = pd.concat([{chart_data}], axis=1).reset_index()".format(
                  chart_data=", ".join(
                      ["chart_data_{}".format(k) for k in aggs]
                  )
              )
          )
          ret_data = pd.concat(all_calculated_aggs, axis=1)
          ret_data.index.names = idx_cols
          return ret_data, all_code, all_calculated_cols
      all_code.append(
          "chart_data = chart_data_{}.reset_index()".format(
              list(aggs.keys())[0]
          )
      )
      return all_calculated_aggs[0], all_code, all_calculated_cols
  
imports: import copy
  import numpy
  import pandas
  import dtale.global_state
  import dtale.pandas_util
  from dtale.column_analysis import handle_cleaners
  from dtale.constants import CHART_JOINER_CHAR
  from dtale.query import build_col_key, run_query
  from dtale.utils import ChartBuildingError, build_formatters, classify_type, find_dtype, find_dtype_formatter, flatten_lists, get_dtypes, json_int, make_list, triple_quote
label_desc: Use image node_id 15 for calling a global function with example usage: compute_aggs(df, groups, aggs, idx_cols, group_col, dropna) and returns: all_calculated_aggs,  all_code,  all_calculated_cols, ret_data,  all_code,  all_calculated_cols