code: def convertUFO1OrUFO2KerningToUFO3Kerning(
      kerning, groups, glyphSet=()
  ):
      # gather known kerning groups based on the prefixes
      (
          firstReferencedGroups,
          secondReferencedGroups,
      ) = findKnownKerningGroups(groups)
      # Make lists of groups referenced in kerning pairs.
      for first, seconds in list(kerning.items()):
          if first in groups and first not in glyphSet:
              if not first.startswith("public.kern1."):
                  firstReferencedGroups.add(first)
          for second in list(seconds.keys()):
              if second in groups and second not in glyphSet:
                  if not second.startswith("public.kern2."):
                      secondReferencedGroups.add(second)
      # Create new names for these groups.
      firstRenamedGroups = {}
      for first in firstReferencedGroups:
          # Make a list of existing group names.
          existingGroupNames = list(groups.keys()) + list(
              firstRenamedGroups.keys()
          )
          # Remove the old prefix from the name
          newName = first.replace("@MMK_L_", "")
          # Add the new prefix to the name.
          newName = "public.kern1." + newName
          # Make a unique group name.
          newName = makeUniqueGroupName(newName, existingGroupNames)
          # Store for use later.
          firstRenamedGroups[first] = newName
      secondRenamedGroups = {}
      for second in secondReferencedGroups:
          # Make a list of existing group names.
          existingGroupNames = list(groups.keys()) + list(
              secondRenamedGroups.keys()
          )
          # Remove the old prefix from the name
          newName = second.replace("@MMK_R_", "")
          # Add the new prefix to the name.
          newName = "public.kern2." + newName
          # Make a unique group name.
          newName = makeUniqueGroupName(newName, existingGroupNames)
          # Store for use later.
          secondRenamedGroups[second] = newName
      # Populate the new group names into the kerning dictionary as needed.
      newKerning = {}
      for first, seconds in list(kerning.items()):
          first = firstRenamedGroups.get(first, first)
          newSeconds = {}
          for second, value in list(seconds.items()):
              second = secondRenamedGroups.get(second, second)
              newSeconds[second] = value
          newKerning[first] = newSeconds
      # Make copies of the referenced groups and store them
      # under the new names in the overall groups dictionary.
      allRenamedGroups = list(firstRenamedGroups.items())
      allRenamedGroups += list(secondRenamedGroups.items())
      for oldName, newName in allRenamedGroups:
          group = list(groups[oldName])
          groups[newName] = group
      # Return the kerning and the groups.
      return (
          newKerning,
          groups,
          dict(side1=firstRenamedGroups, side2=secondRenamedGroups),
      )
  
label_desc: Use image node_id 1 for calling a global function with example usage: convertUFO1OrUFO2KerningToUFO3Kerning(kerning, groups, glyphSet) and returns: newKerning,  groups,  dict