code: def test_generate_primitives_coverage_doc(self):
      harnesses = test_harnesses.all_harnesses
      print(f"Found {len(harnesses)} harnesses")
  
      harness_groups: dict[
          str, Sequence[test_harnesses.Harness]
      ] = collections.defaultdict(list)
  
      def unique_hash(
          h: test_harnesses.Harness, l: test_harnesses.Limitation
      ):
          return (
              h.group_name,
              l.description,
              l.devices,
              tuple(np.dtype(d).name for d in l.dtypes),
          )
  
      unique_limitations: dict[
          Any, tuple[test_harnesses.Harness, test_harnesses.Limitation]
      ] = {}
  
      for h in harnesses:
          harness_groups[h.group_name].append(h)
          for l in h.jax_unimplemented:
              if l.enabled:
                  unique_limitations[hash(unique_hash(h, l))] = (h, l)
  
      primitive_coverage_table = [
          """
  | Primitive | Total test harnesses | dtypes supported on at least one device | dtypes NOT tested on any device |
  | --- | --- | --- | --- |"""
      ]
      all_dtypes = set(jtu.dtypes.all)
  
      for group_name in sorted(harness_groups.keys()):
          hlist = harness_groups[group_name]
          dtypes_tested = set()  # Tested on at least some device
          for h in hlist:
              dtypes_tested = dtypes_tested.union({h.dtype})
  
          primitive_coverage_table.append(
              f"| {group_name} | {len(hlist)} | "
              f"{test_harnesses.dtypes_to_str(dtypes_tested)} | "
              f"{test_harnesses.dtypes_to_str(all_dtypes - dtypes_tested)} |"
          )
  
      print(f"Found {len(unique_limitations)} unique limitations")
      primitive_unimpl_table = [
          """
  | Affected primitive | Description of limitation | Affected dtypes | Affected devices |
  | --- | --- | --- | --- |"""
      ]
      for h, l in sorted(
          unique_limitations.values(),
          key=lambda pair: unique_hash(*pair),
      ):
          devices = ", ".join(l.devices)
          primitive_unimpl_table.append(
              f"|{h.group_name}|{l.description}|"
              f"{test_harnesses.dtypes_to_str(l.dtypes, empty_means_all=True)}|{devices}|"
          )
  
      if not os.environ.get("JAX_OUTPUT_LIMITATIONS_DOC"):
          raise unittest.SkipTest(
              "Set JAX_OUTPUT_LIMITATIONS_DOC=1 to enable the generation of the documentation"
          )
      # The CPU/GPU have more supported types than TPU.
      self.assertEqual(
          "cpu",
          jtu.device_under_test(),
          "The documentation can be generated only on CPU",
      )
      self.assertTrue(
          config.enable_x64.value,
          "The documentation must be generated with JAX_ENABLE_X64=1",
      )
  
      with open(
          os.path.join(
              os.path.dirname(__file__),
              "../g3doc/jax_primitives_coverage.md.template",
          )
      ) as f:
          template = f.read()
      output_file = os.path.join(
          os.path.dirname(__file__),
          "../g3doc/jax_primitives_coverage.md",
      )
  
      with open(output_file, "w") as f:
          f.write(
              template.replace(
                  "{{generation_date}}", str(datetime.date.today())
              )
              .replace("{{nr_harnesses}}", str(len(harnesses)))
              .replace("{{nr_primitives}}", str(len(harness_groups)))
              .replace(
                  "{{primitive_unimpl_table}}",
                  "\n".join(primitive_unimpl_table),
              )
              .replace(
                  "{{primitive_coverage_table}}",
                  "\n".join(primitive_coverage_table),
              )
          )
  
file_path: jax/jax/experimental/jax2tf/tests/jax_primitives_coverage_test.py
imports: import collections
  from collections.abc import Sequence
  import datetime
  import logging
  import os
  from typing import Any
  import unittest
  from absl.testing import absltest
  import jax
  from jax._src import config
  from jax._src import test_util
  from jax._src import maps
  import numpy
  from jax._src.internal_test_util import test_harnesses
label_desc: Use image node_id 2 for calling the JaxPrimitiveTest obj's underlying member method code with example usage: obj.test_generate_primitives_coverage_doc() and returns: h,  l,  l,  tuple