code: def field(*, metadata=None, kw_only=dataclasses.MISSING, **kwargs):
      """Wrapper for dataclassess.field that adds support for kw_only fields.
  
      Args:
        metadata: A mapping or None, containing metadata for the field.
        kw_only: If true, the field will be moved to the end of `__init__`'s
          parameter list.
        **kwargs: Keyword arguments forwarded to `dataclasses.field`
  
      Returns:
        A `dataclasses.Field` object.
      """
      if kw_only is not dataclasses.MISSING and kw_only:
          if (
              kwargs.get("default", dataclasses.MISSING)
              is dataclasses.MISSING
              and kwargs.get("default_factory", dataclasses.MISSING)
              is dataclasses.MISSING
          ):
              raise ValueError(
                  "Keyword-only fields with no default are not supported."
              )
          if metadata is None:
              metadata = {}
          metadata[KW_ONLY] = True
      return dataclasses.field(metadata=metadata, **kwargs)
  
file_path: flax/flax/linen/kw_only_dataclasses.py
imports: import dataclasses
  import functools
  import inspect
  from types import MappingProxyType
  from typing import Any, TypeVar
  import typing_extensions
  import flax
label_desc: Use image node_id 1 for calling a global function with example usage: field() and returns: dataclasses