How to use 'gym.acquire_net_contact_force_tensor' to detect collision?

I want to use 'gym.acquire_net_contact_force_tensor to detect whether there is a collision between object A and object B. However, I want to read data only when object A collides with object B (not with object C). What should I do to detect this collision?