Approximation of relation functions and attention mechanisms