from typing import Optional


def int_range_to_string(
    begin_optional: Optional[int] = None,
    end_optional: Optional[int] = None,
    unit: Optional[str] = None,
    default_begin_value: str = "",
    default_end_value: str = "",
) -> Optional[str]:
    """
    Change range int to string for TFDS.

    Parameters
    ----------
    begin_optional : Optional[int], optional, default=None
        Start value for string range.
    end_optional : Optional[int], optional, default=None
        End value for string range.
    unit : Optional[str], optional, default=None
        Unit for range.
    default_begin_value : str, optional, default=""
        Default value for begin.
    default_end_value : str, optional, default=""
        Default value for end.

    Returns
    -------
    Optional[str]
        Range string for TFDS load.

    Examples
    --------
    >>> int_range_to_string(begin_optional=30, unit="%")
    "30%:"
    >>> int_range_to_string(begin_optional=10, end_optional=50, unit="%")
    "10%:50%"
    >>> self.assertEqual(int_range_to_string(unit="%"), None)
    None
    """
    result: Optional[str] = None
    if begin_optional or end_optional:
        begin_string: str = (
            str(begin_optional) if begin_optional else default_begin_value
        )
        end_string: str = str(end_optional) if end_optional else default_end_value
        if unit:
            begin_string = (
                begin_string + unit
                if begin_string is not default_begin_value
                else begin_string
            )
            end_string = (
                end_string + unit if end_string is not default_end_value else end_string
            )
        result = "{}:{}".format(begin_string, end_string)
    return result