code: def metrics(results_fh):
      """
      Compute metrics from collated HumanEval results.
  
      Args:
          results_fh (File Stream): A file stream containing the collated results in CSV.
      """
  
      reader = csv.reader(results_fh)
      first_row = next(reader)  # Read the first line
  
      num_trials = (
          len(first_row) - 1
      )  # Don't count the first column (TestId)
      max_turns = 0
      num_rows = 0
  
      # Load the results. We'll need to iterate over them a few times.
      results = list()
      for row in reader:
          num_rows += 1
  
          name = row[0]
          trials = [
              (None if v.strip() == "" else int(v)) for v in row[1:]
          ]
          for v in trials:
              if v is not None:
                  max_turns = max(max_turns, v)
          results.append([name, trials])
  
      # Print the header
      header = ["Trial"]
      for i in range(1, max_turns + 1):
          header.append("cumulative_passes_by_turn_" + str(i))
      header.append("fails")
      header.append("missing")
      print(",".join(header))
  
      # Compute the metrics
      def _metrics_for_trial(t):
          counts = [None]
          fails = 0
          missing = 0
  
          # Compute cumulative passes for each conversation turn
          for i in range(1, max_turns + 1):
              counts.append(0)
              assert len(counts) == i + 1
  
              for r in results:
                  v = r[1][t]
                  if v is not None:
                      v = int(v)
                      if 0 <= v and v <= i:
                          counts[i] += 1
  
          # Count missing and failed
          for r in results:
              v = r[1][t]
              if v is None:
                  missing += 1
              elif int(v) < 0:
                  fails += 1
  
          # Prepare the row in the format specified by the header
          return (
              str(t)
              + ","
              + ",".join([str(v) for v in counts[1:]])
              + ","
              + str(fails)
              + ","
              + str(missing)
          )
  
      # Print each row
      for t in range(0, num_trials):
          print(_metrics_for_trial(t))
  
imports: import os
  import sys
  import argparse
  import csv
label_desc: Use image node_id 1 for calling a global function with example usage: metrics(results_fh) and returns: unknown