def sign_extend(value: int, bits: int) ->int:
    """Sign extend an unsigned integer into a python signed integer.

    :param value: The value that should be sign extended.
    :param bits: The number of bits in the input integer.
    """
    sign_bit = 1 << bits - 1
    return (value & sign_bit - 1) - (value & sign_bit)
