code: def _serialize_pytreedef(
      builder: flatbuffers.Builder, p: tree_util.PyTreeDef
  ) -> int:
      node_data = p.node_data()
      children = p.children()
  
      children_vector_offset = None
      children_names_vector_offset = None
      if children:
          children_vector_offset = _serialize_array(
              builder, _serialize_pytreedef, children
          )
  
      if node_data is None:  # leaf
          kind = ser_flatbuf.PyTreeDefKind.leaf
      elif node_data[0] is type(None):
          kind = ser_flatbuf.PyTreeDefKind.none
      elif node_data[0] is tuple:
          kind = ser_flatbuf.PyTreeDefKind.tuple
      elif node_data[0] is list:
          kind = ser_flatbuf.PyTreeDefKind.list
      elif node_data[0] is dict:
          kind = ser_flatbuf.PyTreeDefKind.dict
          assert len(node_data[1]) == len(children)
          children_names_vector_offset = _serialize_array(
              builder, lambda b, s: b.CreateString(s), node_data[1]
          )
      else:
          raise NotImplementedError(
              f"serializing PyTreeDef {node_data}"
          )
  
      ser_flatbuf.PyTreeDefStart(builder)
      ser_flatbuf.PyTreeDefAddKind(builder, kind)
      if children_vector_offset:
          ser_flatbuf.PyTreeDefAddChildren(
              builder, children_vector_offset
          )
      if children_names_vector_offset:
          ser_flatbuf.PyTreeDefAddChildrenNames(
              builder, children_names_vector_offset
          )
      return ser_flatbuf.PyTreeDefEnd(builder)
  
imports: from typing import Callable, TypeVar
  from collections.abc import Sequence
  from jax._src import core
  from jax._src import dtypes
  from jax._src import effects
  from jax._src import tree_util
  from jax._src.lib import xla_client
  from jax.experimental.export import serialization_generated
  from jax.experimental.export import _export
  from jax.experimental import export
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: _serialize_pytreedef(builder, p) and returns: ser_flatbuf