code: def MakeSummary(pcoll, metric_fn, metric_keys):
      """Summary PTransform used in Dataflow."""
      return (
          pcoll
          | "ApplyMetricFnPerInstance" >> beam.Map(metric_fn)
          | "PairWith1" >> beam.Map(lambda tup: (*tup, 1))
          | "SumTuple"
          >> beam.CombineGlobally(
              beam.combiners.TupleCombineFn(
                  *([sum] * (len(metric_keys) + 1))
              )
          )
          | "AverageAndMakeDict"
          >> beam.Map(
              lambda tup: dict(
                  [
                      (name, tup[i] / tup[-1])
                      for i, name in enumerate(metric_keys)
                  ]
                  + [("count", tup[-1])]
              )
          )
      )
  
file_path: airflow/airflow/providers/google/cloud/utils/mlengine_prediction_summary.py
imports: from __future__ import annotations
  import argparse
  import base64
  import json
  import logging
  import os
  import apache_beam
  import dill
  from apache_beam.coders.coders import Coder
label_desc: Use image node_id 1 for calling a global function with example usage: MakeSummary(pcoll, metric_fn, metric_keys) and returns: unknown