code: def build_code(self):
      index, agg, dropna = (
          self.cfg.get(p) for p in ["index", "agg", "dropna"]
      )
      dropna = dropna if dropna is not None else True
      agg_type, func, cols = (
          agg.get(p) for p in ["type", "func", "cols"]
      )
      code = []
      if (agg_type == "func" and func == "gmean") or (
          agg_type != "func" and "gmean" in cols.values()
      ):
          code.append("\nfrom scipy.stats import gmean\n\n")
  
      if index:
          index = "', '".join(index)
          if agg_type == "func":
              if "count_pct" == agg:
                  code.append(
                      (
                          "total_records = len(df)\n"
                          "df = df{groupby}\n"
                          "counts = df.size()\n"
                          "df = pd.DataFrame({'Count': counts, 'Percentage': (counts / total_records) * 100})"
                      )
                  )
                  return code
              agg_str = (
                  ".agg(gmean)"
                  if agg == "gmean"
                  else ".{}()".format(agg)
              )
              if cols is not None:
                  code.append(
                      "df = df{groupby}['{columns}']{agg}".format(
                          groupby=pandas_util.groupby_code(
                              index, dropna=dropna
                          ),
                          columns="', '".join(cols),
                          agg=agg_str,
                      )
                  )
                  return code
              code.append(
                  "df = df{groupby}{agg}".format(
                      groupby=pandas_util.groupby_code(
                          index, dropna=dropna
                      ),
                      agg=agg_str,
                  )
              )
              return code
          code += [
              "df = df{groupby}.aggregate(".format(
                  groupby=pandas_util.groupby_code(index, dropna=dropna)
              )
              + "{",
              ",\n".join(
                  "\t'{col}': ['{aggs}']".format(
                      col=col, aggs=", ".join(custom_str_handler(aggs))
                  )
                  for col, aggs in cols.items()
              ),
              "})",
              "df.columns = [' '.join([str(c) for c in col]).strip() for col in df.columns.values]",
          ]
          return "\n".join(code)
  
      if cols:
          code.append("df = df[[{}]]".format("', '".join(cols)))
      if agg_type == "func":
          agg_str = (
              ".apply(gmean)" if agg == "gmean" else ".{}()".format(agg)
          )
          code += ["df = df{}".format(agg_str), "df = df.to_frame().T"]
          return code
      code += [
          "df = df.aggregate({"
          + ",\n".join(
              "\t'{col}': ['{aggs}']".format(
                  col=col, aggs=", ".join(custom_agg_handler(aggs))
              )
              for col, aggs in cols.items()
          )
          + "})",
          "df = df.to_frame().T",
      ]
      return code
  
imports: import pandas
  from scipy import stats
  import dtale.global_state
  import dtale.pandas_util
  from dtale.query import run_query
  from dtale.utils import make_list
label_desc: Use image node_id 3 for calling the AggregateBuilder obj's underlying member method code with example usage: obj.build_code() and returns: code, str, code, code, code, code