<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _normalize_mirror_settings(self):
 """ Validates the group mirroring settings and converts them as necessary. """


        def malformed_mirror_groups_except():
            return ImproperlyConfigured(
                "{} must be a collection of group names".format(
                    self.settings._name("MIRROR_GROUPS_EXCEPT")
                )
            )

        def malformed_mirror_groups():
            return ImproperlyConfigured(
                "{} must be True or a collection of group names".format(
                    self.settings._name("MIRROR_GROUPS")
                )
            )

        mge = self.settings.MIRROR_GROUPS_EXCEPT
        mg = self.settings.MIRROR_GROUPS

        if mge is not None:
            if isinstance(mge, (set, frozenset)):
                pass
            elif isinstance(mge, (list, tuple)):
                mge = self.settings.MIRROR_GROUPS_EXCEPT = frozenset(mge)
            else:
                raise malformed_mirror_groups_except()

            if not all(isinstance(value, str) for value in mge):
                raise malformed_mirror_groups_except()
            elif mg:
                warnings.warn(
                    ConfigurationWarning(
                        "Ignoring {} in favor of {}".format(
                            self.settings._name("MIRROR_GROUPS"),
                            self.settings._name("MIRROR_GROUPS_EXCEPT"),
                        )
                    )
                )
                mg = self.settings.MIRROR_GROUPS = None

        if mg is not None:
            if isinstance(mg, (bool, set, frozenset)):
                pass
            elif isinstance(mg, (list, tuple)):
                mg = self.settings.MIRROR_GROUPS = frozenset(mg)
            else:
                raise malformed_mirror_groups()

            if isinstance(mg, (set, frozenset)) and (
                not all(isinstance(value, str) for value in mg)
            ):
                raise malformed_mirror_groups()