code: def traverse_module(
      m: TraverseInput,
      acc: Accumulator[State],
      update_cb: TraverseUpdateCallable[TraverseInput, State],
      target_types: Tuple[Type[Any], ...],
  ) -> State:
      """
      Recursively traverses `m`, accumulating in `acc` a path and a state until it finds an object of
      type in `target_types` to apply `update_cb` to update the accumulator `acc` and/or the object.
  
      :param m: tf.Module, tf.Variable or gpflow.Parameter
      :param acc: Tuple of path and state
      :param update_cb: Callable
      :param target_types: target class types
      :return:
      """
      path, state = acc
  
      new_state = state
  
      if isinstance(m, target_types):
          return update_cb(m, path, state)
  
      if isinstance(m, (list, tuple)):
          for term_idx, subterm in enumerate(m):
              new_acc = (f"{path}[{term_idx}]", new_state)
              new_state = traverse_module(
                  subterm, new_acc, update_cb, target_types
              )
      elif isinstance(m, dict):
          for term_idx, subterm in m.items():
              new_acc = (f"{path}['{term_idx}']", new_state)
              new_state = traverse_module(
                  subterm, new_acc, update_cb, target_types
              )
      elif isinstance(m, tf.Module):
          for name, submodule in vars(m).items():
              ignored_attributes = m._TF_MODULE_IGNORED_PROPERTIES
              # NOTE(awav): since tfp version 0.10.0, tfp.bijectors.Bijector instances have
              # `_parameters` dictionary with "self" references that cause
              # infinite recursive loop.
              if isinstance(m, tfp.bijectors.Bijector):
                  ignored_attributes = ignored_attributes.union(
                      {"_parameters"}
                  )
              if name in ignored_attributes:
                  continue
              new_acc = (f"{path}.{name}", new_state)
              new_state = traverse_module(
                  submodule, new_acc, update_cb, target_types
              )
      return new_state
  
imports: import copy
  import re
  from functools import lru_cache
  from typing import Any, Callable, Dict, Mapping, Optional, Pattern, Tuple, Type, TypeVar, Union
  import numpy
  import tensorflow
  import tensorflow_probability
  from packaging.version import Version
  from tabulate import tabulate
  from tensorflow.python.util.object_identity import Reference
  from ..base import AnyNDArray, Parameter
  from ..config import default_summary_fmt
label_desc: Use image node_id 12 for calling a global function with example usage: traverse_module(m, acc, update_cb, target_types) and returns: new_state, update_cb