def _try_replace_value(typ: ProperType, base_type: Instance | None, has_empty_label: bool) -> MypyType:
    """
    Attempt to replace a label with a modified version.

    If the value is of any type, then attempt to use the base type of the choices type.

    If the choices type has `__empty__` defined, then make the value type optional.
    """
    has_unknown_base = isinstance(typ, AnyType)

    if has_empty_label and has_unknown_base and base_type is not None:
        return make_optional_type(base_type)

    if has_empty_label:
        return make_optional_type(typ)

    if has_unknown_base and base_type is not None:
        return base_type

    return typ

    Attempt to replace a label with a modified version.

    If the value is of any type, then attempt to use the base type of the choices type.

    If the choices type has `__empty__` defined, then make the value type optional.
    
mypy_django_plugin/transformers/choices.py