code: def dataclass(
      cls: tp.Optional[tp.Type[A]] = None,
      init: bool = True,
      repr: bool = True,
      eq: bool = True,
      order: bool = False,
      unsafe_hash: bool = False,
      frozen: bool = False,
  ) -> tp.Union[tp.Type[A], tp.Callable[[tp.Type[A]], tp.Type[A]]]:
      def decorator(cls: tp.Type[A]) -> tp.Type[A]:
          cls = dataclasses.dataclass(
              init=init,
              repr=repr,
              eq=eq,
              order=order,
              unsafe_hash=unsafe_hash,
              frozen=frozen,
          )(cls)
          if issubclass(cls, nnx.Module):
  
              def hash_fn(module: nnx.Module):
                  return hash(module._module__state.id)
  
              cls.__hash__ = hash_fn
  
          return cls
  
      if cls is None:
          return decorator
  
      return decorator(cls)
  
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 7 for calling a global function with example usage: dataclass(cls, init, repr, eq, order, unsafe_hash, frozen) and returns: decorator, cls, decorator, hash