Range-aware Positional Encoding via High-order Pretraining: Theory and Practice