code: def treenode_field(
      *,
      default: tp.Any = dataclasses.MISSING,
      default_factory: tp.Any = dataclasses.MISSING,
      init: bool = True,
      repr: bool = True,
      hash: tp.Optional[bool] = None,
      compare: bool = True,
      metadata: tp.Optional[tp.Mapping[str, tp.Any]] = None,
  ):
      if metadata is None:
          metadata = {}
      else:
          metadata = dict(metadata)
  
      if "nnx_variable_constructor" in metadata:
          raise ValueError(
              "'nnx_variable_constructor' found in metadata"
          )
  
      metadata[
          "nnx_variable_constructor"
      ] = lambda value: pytreelib.TreeNode(value)
  
      return field(
          default=default,
          default_factory=default_factory,
          init=init,
          repr=repr,
          hash=hash,
          compare=compare,
          metadata=metadata,
      )
  
file_path: flax/flax/experimental/nnx/nnx/dataclasses.py
imports: import dataclasses
  import typing
  import typing_extensions
  from flax.experimental import nnx
  from flax.experimental.nnx.nnx import pytreelib, variables
label_desc: Use image node_id 2 for calling a global function with example usage: treenode_field() and returns: field