How to control fan speed based on GPU index instead of fan index

Hello,
I searched a lot before writing this post but I didn’t find a good answer. I want to control fan speed from command line based on GPU index not fan index. I mean when I execute this command:

nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=70

It will set the speed for the first fan only, not the whole GPU fans. So if I have multi GPU system that has a dual fans GPUs and three fans GPUs I can’t know (programmaticly) what fan index belong to what GPU. Is there a better way to achieve this? I hope my question is clear.

Thank you in advance!

AFAIK, this has always been an issue, basing on the fact that there has been no development on the nvml lib for years, also resulting in this:
https://forums.developer.nvidia.com/t/request-gpu-memory-junction-temperature-via-nvidia-smi-or-nvml-api/168346/11