import dataclasses
from typing import Any


def _is_optional(field: "dataclasses.Field[Any]") -> bool:
    """Determine if the given :class:`dataclasses.Field` is optional.

    :param field:
        Field to determine if it is optional.

    :return:
        True if the `field` is optional, otherwise False.
    """
    return (
        field.init
        and (field.default is not dataclasses.MISSING)
        or (field.default_factory is not dataclasses.MISSING)  # type: ignore
    )