code: def write_and_check_harnesses(
      io: Io,
      save_directory: str,
      *,
      filter_harness: Callable[[str], bool] | None = None,
      for_platforms: Sequence[str] = ("cpu", "tpu"),
      verbose=False,
  ):
      logging.info(
          "Writing and checking harnesses at %s", save_directory
      )
      nr_harnesses = len(primitive_harness.all_harnesses)
      for i, harness in enumerate(primitive_harness.all_harnesses):
          if i % 100 == 0:
              logging.info(
                  "Trying cross-lowering for harness #%d/%d",
                  i,
                  nr_harnesses,
              )
          enable_xla = harness.params.get("enable_xla", True)
          if not enable_xla:
              if verbose:
                  logging.info(
                      "Skip %s due to enable_xla=False",
                      harness.fullname,
                  )
              continue
  
          if filter_harness is not None and not filter_harness(
              harness.fullname
          ):
              if verbose:
                  logging.info(
                      "Skip %s due to filter_harness", harness.fullname
                  )
              continue
  
          write_and_check_harness(
              harness, io, save_directory, for_platforms=for_platforms
          )
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import contextlib
  import dataclasses
  import os
  import re
  from typing import Callable, Optional
  import zlib
  from absl import app
  from absl import logging
  import numpy.random
  import jax
  from jax import config
  from jax.experimental import jax2tf
  from jax._src import test_util
  from jax.experimental.jax2tf.tests import primitive_harness
label_desc: Use image node_id 2 for calling a global function with example usage: write_and_check_harnesses(io, save_directory) without return types