code: def format_hyperedges(
      engine: Engine,
      events: DataframeLike,
      entity_types: List[str],
      defs: HyperBindings,
      drop_na: bool,
      drop_edge_attrs: bool,
      debug: bool = False,
  ) -> DataframeLike:
      is_using_categories = len(defs.categories.keys()) > 0
      cat_lookup = make_reverse_lookup(defs.categories)
  
      # mt_pdf = pd.DataFrame({
      #     **{
      #         **({defs.category: pd.Series([], dtype='object')} if is_using_categories else {}),
      #         defs.edge_type: pd.Series([], dtype='object'),
      #         defs.attrib_id: pd.Series([], dtype='object'),
      #         defs.event_id: pd.Series([], dtype='object'),
      #         defs.category: pd.Series([], dtype='object'),
      #         defs.node_id: pd.Series([], dtype='object'),
      #     },
      #     **({
      #         x: pd.Series([], dtype=events[x].dtype)
      #         for x in entity_types
      #     } if drop_edge_attrs else {
      #         x: pd.Series([], dtype=events[x].dtype)
      #         for x in events.columns
      #     })
      # })
  
      subframes = []
      for col in sorted(entity_types):
          fields = list(
              set(
                  [defs.event_id]
                  + (
                      [x for x in events.columns]
                      if not drop_edge_attrs
                      else [col]
                  )
              )
          )
          raw = events[fields]
          if drop_na:
              logger.debug(
                  "dropping na [ %s ] from available [ %s]  (fields: [ %s ])",
                  col,
                  raw.columns,
                  fields,
              )
              raw = raw.dropna(subset=[col])
          raw = raw.copy()
          if is_using_categories:
              raw[defs.edge_type] = col2cat(cat_lookup, col)
              raw[defs.category] = col
          else:
              raw[defs.edge_type] = col
          try:
              raw[defs.attrib_id] = (
                  col2cat(cat_lookup, col) + defs.delim
              ) + raw[col].astype(str).fillna(defs.null_val).astype(str)
          except NotImplementedError:
              logger.warning(
                  "Did not create hyperedges for column %s as does not support astype(str)",
                  col,
              )
              continue
          if drop_edge_attrs:
              logger.debug(
                  "dropping val col [ %s ] from [ %s ]",
                  col,
                  raw.columns,
              )
              raw = raw.drop(columns=[col])
              logger.debug("dropped => [ %s ]", raw.columns)
          if debug and (engine in [Engine.DASK, Engine.DASK_CUDF]):
              raw = raw.persist()
              raw.compute()
          subframes.append(raw)
  
      if len(subframes):
          result_cols = list(
              set(
                  (
                      [
                          x
                          for x in events.columns.tolist()
                          if not x == defs.node_type
                      ]
                      if not drop_edge_attrs
                      else []
                  )
                  + [
                      defs.edge_type,
                      defs.attrib_id,
                      defs.event_id,
                  ]  # noqa: W503
                  + ([defs.category] if is_using_categories else [])
              )
          )  # noqa: W503
          if debug and (engine in [Engine.DASK, Engine.DASK_CUDF]):
              # subframes = [df.persist() for df in subframes]
              for df in subframes:
                  logger.debug("edge sub: %s", df.dtypes)
          out = concat(subframes, engine, debug).reset_index(drop=True)[
              result_cols
          ]
          if debug and (engine in [Engine.DASK, Engine.DASK_CUDF]):
              out = out.persist()
              out.compute()
              logger.debug("////format_hyperedges")
          return out
      else:
          return mt_series(engine)
  
imports: from typing import TYPE_CHECKING, Any, Dict, List, Optional
  from .Engine import Engine, DataframeLike, DataframeLocalLike
  import numpy, pandas, pyarrow, sys
  from .util import setup_logger
label_desc: Use image node_id 14 for calling a global function with example usage: format_hyperedges(engine, events, entity_types, defs, drop_na, drop_edge_attrs, debug) and returns: out, mt_series