Answer
Inside the drinking bird, heat enters the lower body (the hot reservoir) and leaves via the cold beak (the cold reservoir). Mechanical energy (the rocking motion) is produced.
A heat engine is precisely a device that uses heat as input and produces mechanical work.