code: def author_id_normalize_and_schema(uid, schema=None):
      
      def _get_uid_normalized_in_schema(_uid, _schema):
          regex, template = _RE_AUTHORS_UID[_schema]
          match = regex.match(_uid)
          if match:
              return template.format(match.group('uid'))
  
      if idutils.is_orcid(uid) and schema in (None, 'ORCID'):
          return idutils.normalize_orcid(uid), 'ORCID'
  
      if schema and schema not in _RE_AUTHORS_UID:
          # Schema explicitly specified, but this function can't handle it
          raise UnknownUIDSchema(uid)
  
      if schema:
          normalized_uid = _get_uid_normalized_in_schema(uid, schema)
          if normalized_uid:
              return normalized_uid, schema
          else:
              raise SchemaUIDConflict(schema, uid)
  
      match_schema, normalized_uid = None, None
      for candidate_schema in _RE_AUTHORS_UID:
          candidate_uid = _get_uid_normalized_in_schema(uid, candidate_schema)
          if candidate_uid:
              if match_schema:
                  # Valid against more than one candidate schema, ambiguous
                  raise UnknownUIDSchema(uid)
              match_schema = candidate_schema
              normalized_uid = candidate_uid
  
      if match_schema:
          return normalized_uid, match_schema
  
      # No guessess have been found
      raise UnknownUIDSchema(uid)
docs: Detect and normalize an author UID schema.
  
      Args:
          uid (string): a UID string
          schema (string): try to resolve to schema
  
      Returns:
          Tuple[string, string]: a tuple (uid, schema) where:
          - uid: the UID normalized to comply with the id.json schema
          - schema: a schema of the UID or *None* if not recognised
  
      Raise:
          UnknownUIDSchema: if UID is too little to definitively guess the schema
          SchemaUIDConflict: if specified schema is not matching the given UID