<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_context( context: Context, formatter: typing.Union[str, Formatter] = "full" ) -> str: """Output the a context dictionary as a string."""

    if not context:
        return ""

    if callable(formatter):
        formatter_func = formatter
    else:
        if formatter in CONTEXT_FORMATTERS:
            formatter_func = CONTEXT_FORMATTERS[formatter]
        else:
            raise ValueError(f'Invalid context format: "{formatter}"')
    return formatter_func(context)