Ansible Bonding with automatic recongition of interfaces

I have some issues with my project. I need to bond two interfaces, automatically choosing the two with 25Gbit speed. I’m able to make a normal bonding selecting the interface names, I’m able to filter the interfaces through speed too, but I’m lost trying to connect both ideas.

This is my Bonding.yml

Where does interfaces_per_speed come from?
Can you post all the data/vars/etc?