<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dict(self, flat: bool=True) -> Dict[Any, Any]: """Convert the multidict to a plain dictionary. Arguments: flat: If True only return the a value for each key, if False return all values as lists. """

        if flat:
            return {key: value for key, value in self.items()}  # type: ignore
        else:
            return {key: self.getall(key) for key in self}