Based on the features output of the model you could start by calculating the class centers.
I don’t see a clear description how these centers are calculated so I assume they are just the mean of the features corresponding to the current class?
If so, you could use the target to index features and thus split it into different class features.
Once this is done, you could then apply the mean to generate the class centers.