docs: def canonicalize_id(reference_id):
      """\
      Returns the canonicalized form of the provided reference_id.
  
      WikiLeaks provides some malformed cable identifiers. If the provided `reference_id`
      is not valid, this method returns the valid reference identifier equivalent.
      If the reference identifier is valid, the reference id is returned unchanged.
  
      Note: The returned canonicalized identifier may not be a valid WikiLeaks identifier
      anymore. In most cases the returned canonical form is identical to the WikiLeaks
      identifier, but for malformed cable identifiers like "09SECTION01OF03SANJOSE525"
      it is not (becomes "09SANJOSE525").
  
      `reference_id`
          The cable identifier to canonicalize
      """
      if u'EMBASSY' in reference_id:
          return reference_id.replace(u'EMBASSY', u'')
      m = _C14N_PATTERN.match(reference_id)
      if m:
          origin = m.group(1)
          return reference_id.replace(origin, _C14N_FIXES[origin])
      return MALFORMED_CABLE_IDS.get(reference_id, INVALID_CABLE_IDS.get(reference_id, reference_id))