do these sensors count sprocket holes.
No.
The sensor(s) for film loading are between the take up and the camera body. Once blocked the camera only runs the wind motor for a predetermined time. If the sensor is blocked before film is put into the camera it will never load. If the sensor never blocks once film is put in the camera it will most likely wind the full roll up onto the take up.
There may be a sensor for thickness on the take up side.
The most likely cause of mid roll rewind that is not initiated by the user is the film is too tight in the film cassette, there is a custom function set for that purpose, or there is a problem with the camera electronics.
Take a roll of film and hold the cassette as it will fit into the camera. Hold the leader against the cassette and turn the center spool end clockwise until it stops turning easily. Now try to pull an inch or two of film from the cassette via the exposed leader and note the tension necessary. Now hold the leader against the cassette and turn it counterclockwise until it becomes hard to turn then pull the leader and note how easy the film is to pull out. This is why it is important to turn the rewind crank in the rewind direction after the film winds to frame 1 without pressing the rewind release on any 35mm camera.
Any sensor(s) in the transport path that sees the spaces between sprocket holes will generate a pulse every time a space between holes blocks the sensor.