docs: def normalize_mode(mode):
      """\
      Returns a (Micro) QR Code mode constant which is equivalent to the
      provided `mode`.
  
      In case the provided `mode` is ``None``, this function returns ``None``.
      Otherwise a mode constant is returned unless the provided parameter cannot
      be mapped to a valid mode. In the latter case, a ModeError is raised.
  
      :param mode: An integer or string or ``None``.
      :raises: ModeError: In case the provided `mode` does not represent a valid
               QR Code mode.
      :rtype: int or None
      """
      if mode is None or (isinstance(mode, int)
                          and mode in consts.MODE_MAPPING.values()):
          return mode
      try:
          return consts.MODE_MAPPING[mode.lower()]
      except:  # KeyError or mode.lower() fails
          raise ModeError('Illegal mode "{0}". Supported values: {1}'
                          .format(mode, ', '.join(sorted(consts.MODE_MAPPING.keys()))))