code: def ToUnicode(label):
      # Step 1: Check for ASCII
      if isinstance(label, bytes):
          pure_ascii = True
      else:
          try:
              label = label.encode("ascii")
              pure_ascii = True
          except UnicodeError:
              pure_ascii = False
      if not pure_ascii:
          # Step 2: Perform nameprep
          label = nameprep(label)
          # It doesn't say this, but apparently, it should be ASCII now
          try:
              label = label.encode("ascii")
          except UnicodeError:
              raise UnicodeError("Invalid character in IDN label")
      # Step 3: Check for ACE prefix
      if not label.startswith(ace_prefix):
          return str(label, "ascii")
  
      # Step 4: Remove ACE prefix
      label1 = label[len(ace_prefix) :]
  
      # Step 5: Decode using PUNYCODE
      result = label1.decode("punycode")
  
      # Step 6: Apply ToASCII
      label2 = ToASCII(result)
  
      # Step 7: Compare the result of step 6 with the one of step 3
      # label2 will already be in lower case.
      if str(label, "ascii").lower() != str(label2, "ascii"):
          raise UnicodeError("IDNA does not round-trip", label, label2)
  
      # Step 8: return the result of step 5
      return result
  
imports: import stringprep, re, codecs
  from unicodedata import ucd_3_2_0
label_desc: Use image node_id 3 for calling a global function with example usage: ToUnicode(label) and returns: result, str