I've disassembled the print head of an old dried-out printer (EPSON Stylus Photo R300) and found a very small part under it, next to the surface with the nozzles. It's 4 mm long, 3 mm wide and 2.5 mm tall. Here's how it looks from its top (the side farther from the PCB):
And here's how it looks from the bottom (the side adjacent to the PCB):
In the actual print head it was mounted at the bottom, as if "looking" at the paper. This part seems to look like a pair of IR receivers/transmitters, but the two appear very similar, and I'm not sure why the printer would try to "look" at the paper.
It's definitely not an optical encoder commonly used to track head position, since that one I've already found and identified, and the part in question was quite far from the striped tape.
So what is this device, and what is its role under the print head?
EDIT in response to the answer: I've tried supplying some power to the device, and indeed one of them appears to be IR LED:




