import dataclasses


def field(pytree_node=True, serialize=True, cache=False, **kwargs):
    """Mark a field of a dataclass to be:

    Args:
        pytree_node: a leaf node in the pytree representation of this dataclass.
            If False this must be hashable
        serialize: If True the node is included in the serialization.
            In general you should not specify this.
        cache: If True this node is a cache and will be reset every time
            fields are modified.
    """
    return dataclasses.field(
        metadata={"pytree_node": pytree_node, "serialize": serialize, "cache": cache},
        **kwargs,
    )