Toilet makes high pitch whine after flushing, but only in the middle of the night
In many areas water pressure is lower at night, to reduce leaks on the network. This will slow filling, and the valve might be 'dithering' at an awkward point, whereas under higher pressure it fills quickly enough to move over the awkward point quickly.