code: def assert_valid(self):
          
  
          for ns_uri, ni in six.iteritems(self.__ns_uri_map):
              if not ni.uri:
                  raise InvalidNamespaceSetError(
                      "URI not set in _NamespaceInfo (id={0}):\n{1}".format(
                          id(ni), ni
                      )
                  )
  
              if ns_uri != ni.uri:
                  raise InvalidNamespaceSetError(
                      "URI mismatch in dict ({0}) and _NamespaceInfo ({1})".format(
                          ns_uri, ni.uri
                      )
                  )
  
              if (ni.preferred_prefix is not None and
                 ni.preferred_prefix not in ni.prefixes):
                  raise InvalidNamespaceSetError(
                      "Namespace {0.uri}: preferred prefix " \
                      '"{0.preferred_prefix}" not in prefixes ' \
                      "{0.prefixes}".format(ni)
                  )
  
              for prefix in ni.prefixes:
                  if not prefix:
                      raise InvalidNamespaceSetError(
                          "Namespace {0.uri}: empty value in prefix " \
                          "set: {0.prefixes}".format(ni)
                      )
                  other_ni = self.__prefix_map.get(prefix)
                  if other_ni is None:
                      raise InvalidNamespaceSetError(
                          'Namespace {0.uri}: prefix "{1}" not in ' \
                          'prefix map'.format(ni, prefix)
                      )
                  if other_ni is not ni:
                      raise InvalidNamespaceSetError(
                          'Namespace {0.uri}: prefix "{1}" maps to ' \
                          'wrong _NamespaceInfo (id={2}, uri={3.uri})'.format(
                              ni, prefix, id(other_ni), other_ni
                          )
                      )
  
          if None in self.__prefix_map:
              # None can be a preferred prefix, but should not be in the
              # prefix map.
              raise InvalidNamespaceSetError("None is in prefix map!")
docs: For debugging; does some sanity checks on this set.  Raises
          InvalidNamespaceSetError if this namespace set is invalid.  Otherwise,
          raises/returns nothing.