<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def maybe_infer_tz(tz, inferred_tz):
 """ If a timezone is inferred from data, check that it is compatible with the user-provided timezone, if any. Parameters tz : tzinfo or None inferred_tz : tzinfo or None Returns ------- tz : tzinfo or None Raises ------ TypeError : if both timezones are present but do not match """

    if tz is None:
        tz = inferred_tz
    elif inferred_tz is None:
        pass
    elif not timezones.tz_compare(tz, inferred_tz):
        raise TypeError('data is already tz-aware {inferred_tz}, unable to '
                        'set specified tz: {tz}'
                        .format(inferred_tz=inferred_tz, tz=tz))
    return tz