T-TAME: Trainable Attention Mechanism for Explaining Convolutional Networks and Vision Transformers