Automatic vertex group assignation

I’m stuck doing an script to assing a different vertex group for every constraint.
Let me explain:

My scene has 578 Empties with a Transformation constraint

For Empty.003, its subtarget is vertex group ‘groupy.003’ from another object named Template.001

Cap2

I have manually assigned that vertex group. Sadly, the 577 other empties have all assigned the same vertex group. Changing all of them one by one will take ages and will drive me crazy.
What I am looking for is an script that takes every empty from that collection (‘empties’) and assign their corresponding vertex group.
For example:

Empty > groupy.000
Empty.001 > groupy.001
Empty.002 > groupy.002
…and so on until
Empty.577 > groupy.577

My crappy Python knowledge only gets too write a variable that includes all of the empties I want to change, but that is all I can do. I have no idea how to continue. Any help?

import bpy

cons = bpy.data.collections[‘empties’].objects

for obj in cons:
obj.TransformConstraint.subtarget = [???!$£%^$$]

I have no idea what Transform constraint does… but I’m trying to learn Blender python API…

What exactly you are trying to do… did I get it correctly;
Your target object “Template.001” has all the vertex groups. Then you have a bunch of empties matching each vertex group by name, and your empties have a transform constraint, where you want to set target to be Template.001, and vertex group is one from template that has the name of the empty?