code: def gen_expected_metrics(
      is_map: bool,
      spilled: bool = False,
      extra_metrics: Optional[List[str]] = None,
  ):
      if is_map:
          metrics = [
              "'num_inputs_received': N",
              "'bytes_inputs_received': N",
              "'num_inputs_processed': N",
              "'bytes_inputs_processed': N",
              "'bytes_inputs_of_submitted_tasks': N",
              "'num_outputs_generated': N",
              "'bytes_outputs_generated': N",
              "'rows_outputs_generated': N",
              "'num_outputs_taken': N",
              "'bytes_outputs_taken': N",
              "'num_outputs_of_finished_tasks': N",
              "'bytes_outputs_of_finished_tasks': N",
              "'num_tasks_submitted': N",
              "'num_tasks_running': Z",
              "'num_tasks_have_outputs': N",
              "'num_tasks_finished': N",
              "'num_tasks_failed': Z",
              "'obj_store_mem_alloc': N",
              "'obj_store_mem_freed': N",
              "'obj_store_mem_cur': Z",
              "'obj_store_mem_peak': N",
              f"""'obj_store_mem_spilled': {"N" if spilled else "Z"}""",
              "'block_generation_time': N",
              "'cpu_usage': Z",
              "'gpu_usage': Z",
          ]
      else:
          metrics = [
              "'num_inputs_received': N",
              "'bytes_inputs_received': N",
              "'num_outputs_taken': N",
              "'bytes_outputs_taken': N",
              "'cpu_usage': Z",
              "'gpu_usage': Z",
          ]
      if extra_metrics:
          metrics.extend(extra_metrics)
      return "{" + ", ".join(metrics) + "}"
  
imports: import re
  import threading
  import time
  from collections import Counter
  from contextlib import contextmanager
  from typing import List, Optional
  from unittest.mock import patch
  import numpy
  import pytest
  import ray
  from ray._private.test_utils import wait_for_condition
  from ray.data._internal.dataset_logger import DatasetLogger
  from ray.data._internal.stats import DatasetStats, StatsManager, _get_or_create_stats_actor, _StatsActor
  from ray.data._internal.util import create_dataset_tag
  from ray.data.block import BlockMetadata
  from ray.data.context import DataContext
  from ray.data.tests.util import column_udf
  from ray.tests.conftest import *
label_desc: Use image node_id 1 for calling a global function with example usage: gen_expected_metrics(is_map, spilled, extra_metrics) and returns: unknown