<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fi_ssn(ssn, allow_temporal_ssn=True):
 """ Validate a Finnish Social Security Number. This validator is based on `django-localflavor-fi`_. .. _django-localflavor-fi: https://github.com/django/django-localflavor-fi/ Examples:: True .. versionadded:: 0.5 :param ssn: Social Security Number to validate :param allow_temporal_ssn: Whether to accept temporal SSN numbers. Temporal SSN numbers are the ones where the serial is in the range [900-999]. By default temporal SSN numbers are valid. """

    if not ssn:
        return False

    result = re.match(ssn_pattern, ssn)
    if not result:
        return False
    gd = result.groupdict()
    checksum = int(gd['date'] + gd['serial'])
    return (
        int(gd['serial']) >= 2 and
        (allow_temporal_ssn or int(gd['serial']) <= 899) and
        ssn_checkmarks[checksum % len(ssn_checkmarks)] ==
        gd['checksum']
    )