You have a rod. It is accelerating. Either it passes through the other objects like a ghost or it pushes them until they accelerate with an equal acceleration.
To accelerate each of them it must exert a force on them (Newton 2nd) and so by Newton 3rd the rod feels an equal an opposite force on each end.
If the rod is free to rotate about the exact center then it will rotate unless the torques are equal. The torques are equal if the forces are equal (its the mid point) the forces on the two ends are themselves equal and opposite to the forces on the masses. So they are equal if the forces on the masses ate equal.
The forces on the masses are such as to produce the same acceleration (the acceleration of the device) so the accelerations are the same. If the accelerations are he same the forces can only be the same if the masses are the same.
This is actually what you see if you are in a frame freely falling due to gravity. In that frame a balance scale is accelerating upwards and the masses fail to torque the balance scale because the inertial masses are equal.
In the frame stationary to the earth we think the scale is not accelerating upwards so we say there is an inertial force (inertial force just means a force that is proportional to inertial mass so that everything feels the same acceleration, the acceleration of the frame when no other forces act). The inertial force is called gravity. If you pretend gravity isn't an inertial force you have to invent passive gravitational mass and then note it exactly equals inertial mass.
But any force proportional to inertial mass is an inertial force and really comes from using a non inertial frame. Gravity included.