code: def _flatten_module(module: "Module", with_keys: bool):
      # Subnodes in the PyTree
      dynamic_field_names = []
      dynamic_field_values = []
      # Static metadata, placed in aux.
      static_field_names = []
      static_field_values = []
      # Python metadata like `__doc__` and `__module__`.
      wrapper_field_names = []
      wrapper_field_values = []
  
      for field_ in dataclasses.fields(module):
          name = field_.name
          try:
              # Not `getattr` so that we don't pick up `property`s.
              value = module.__dict__[name]
          except KeyError:
              # Uninitialised values during `__init__`, or when `property`s overwrite a
              # field.
              continue
          if field_.metadata.get("static", False):
              static_field_names.append(name)
              static_field_values.append(value)
          else:
              dynamic_field_names.append(name)
              if with_keys:
                  dynamic_field_values.append(
                      (jtu.GetAttrKey(name), value)
                  )
              else:
                  dynamic_field_values.append(value)
      sentinel = object()
      for name in _wrapper_field_names:
          value = getattr(module, name, sentinel)
          if value is not sentinel:
              wrapper_field_names.append(name)
              wrapper_field_values.append(value)
      aux = _FlattenedData(
          tuple(dynamic_field_names),
          tuple(static_field_names),
          tuple(static_field_values),
          tuple(wrapper_field_names),
          tuple(wrapper_field_values),
      )
      return tuple(dynamic_field_values), aux
  
imports: import abc
  import dataclasses
  import functools
  import inspect
  import types
  import warnings
  import weakref
  from collections.abc import Callable
  from typing import Any, cast, Optional, Protocol, TYPE_CHECKING, TypeVar, Union
  from typing_extensions import dataclass_transform, ParamSpec
  import jax._src.traceback_util
  import jax.tree_util
  import numpy
  from jaxtyping import Array, Bool, PyTreeDef
  from ._better_abstract import ABCMeta, dataclass
  from ._caches import internal_lru_caches
  from ._doc_utils import doc_repr
  from ._pretty_print import tree_pformat
  from ._tree import tree_equal
label_desc: Use image node_id 8 for calling a global function with example usage: _flatten_module(module, with_keys) and returns: tuple,  aux