code: def tabulate(
      f: Union[
          Callable[..., Any], hk.Transformed, hk.TransformedWithState
      ],
      *,
      columns: Optional[Sequence[str]] = DEFAULT_COLUMNS,
      filters: Optional[Sequence[str]] = DEFAULT_FILTERS,
      tabulate_kwargs={"tablefmt": "grid"},
  ) -> Callable[..., str]:
      # pylint: disable=line-too-long
      """Produces a summarised view of the execution of ``f``.
  
      >>> def f(x):
      ...   return hk.nets.MLP([300, 100, 10])(x)
      >>> x = jnp.ones([8, 28 * 28])
      >>> f = hk.transform(f)
      >>> print(hk.experimental.tabulate(f)(x))
      +-------------------------+------------------------------------------+-----------------+------------+------------+---------------+---------------+
      | Module                  | Config                                   | Module params   | Input      | Output     |   Param count |   Param bytes |
      +=========================+==========================================+=================+============+============+===============+===============+
      | mlp (MLP)               | MLP(output_sizes=[300, 100, 10])         |                 | f32[8,784] | f32[8,10]  |       266,610 |       1.07 MB |
      +-------------------------+------------------------------------------+-----------------+------------+------------+---------------+---------------+
      | mlp/~/linear_0 (Linear) | Linear(output_size=300, name='linear_0') | w: f32[784,300] | f32[8,784] | f32[8,300] |       235,500 |     942.00 KB |
      |  └ mlp (MLP)            |                                          | b: f32[300]     |            |            |               |               |
      +-------------------------+------------------------------------------+-----------------+------------+------------+---------------+---------------+
      | mlp/~/linear_1 (Linear) | Linear(output_size=100, name='linear_1') | w: f32[300,100] | f32[8,300] | f32[8,100] |        30,100 |     120.40 KB |
      |  └ mlp (MLP)            |                                          | b: f32[100]     |            |            |               |               |
      +-------------------------+------------------------------------------+-----------------+------------+------------+---------------+---------------+
      | mlp/~/linear_2 (Linear) | Linear(output_size=10, name='linear_2')  | w: f32[100,10]  | f32[8,100] | f32[8,10]  |         1,010 |       4.04 KB |
      |  └ mlp (MLP)            |                                          | b: f32[10]      |            |            |               |               |
      +-------------------------+------------------------------------------+-----------------+------------+------------+---------------+---------------+
  
      Possible values for ``columns``:
  
      * ``module``: Displays module and method name.
      * ``config``: Displays the constructor arguments used for the module.
      * ``owned_params``: Displays parameters directly owned by this module.
      * ``input``: Displays module inputs.
      * ``output``: Displays module output.
      * ``params_size``: Displays the number of parameters
      * ``params_bytes``: Displays parameter size in bytes.
  
      Possible values for ``filters``:
  
      * ``has_output``: Only include methods returning a value other than ``None``.
      * ``has_params``: Removes methods from modules that do not have parameters.
  
      Args:
        f: A function to transform OR one of the init/apply functions from Haiku
          or the result of :func:`transform` or :func:`transform_with_state`.
        columns: A list of column names to enable.
        filters: A list of filters to apply to remove certain module methods.
        tabulate_kwargs: Keyword arguments to pass to ``tabulate.tabulate(..)``.
  
      Returns:
        A callable that takes the same arguments as ``f`` but returns a string
        summarising the modules used during the execution of ``f``.
  
      See Also:
        :func:`eval_summary`: Raw data used to generate this table.
      """
      # pylint: enable=line-too-long
      f = eval_summary(f)
  
      if columns is None:
          columns = DEFAULT_COLUMNS
      else:
          invalid = [c for c in columns if c not in all_columns]
          if invalid:
              raise ValueError(
                  f"Invalid column(s) {invalid}, valid columns {list(all_columns)}"
              )
  
      if filters is None:
          filters = DEFAULT_FILTERS
      else:
          invalid = [f for f in filters if f not in all_filters]
          if invalid:
              raise ValueError(
                  f"Invalid filter(s) {invalid}, valid filters {list(all_filters)}"
              )
  
      columns = [all_columns[c] for c in columns]
      filters = [all_filters[f] for f in filters]
  
      def generate_summary(*args, **kwargs) -> str:
          """Generates a string summary of the given Haiku function."""
          rows = []
          for method_invocation in f(*args, **kwargs):
              if not all(
                  filter.f(method_invocation) for filter in filters
              ):
                  continue
  
              row = [column.f(method_invocation) for column in columns]
              rows.append(row)
  
          if rows:
              headers = [col.header for col in columns]
              colalign = [col.align for col in columns]
              return tabulate_lib.tabulate(
                  rows,
                  headers=headers,
                  colalign=colalign,
                  **tabulate_kwargs,
              )
          else:
              return "No modules matching filters."
  
      return generate_summary
  
imports: from collections.abc import Mapping, Sequence
  import dataclasses
  import functools
  import pprint
  from typing import Any, Callable, Optional, TypeVar, Union
  from haiku._src import base
  from haiku._src import data_structures
  from haiku._src import module
  from haiku._src import transform
  from haiku._src import utils
  import jax
  import jax.numpy
  import numpy
  import tabulate
label_desc: Use image node_id 11 for calling a global function with example usage: tabulate(f) and returns: generate_summary, tabulate_lib, str