class_docstr: Build similarity matrix for TransRAC
code: def forward(self, query, key, value, attn_mask=None):
      batch_size = query.size(0)
      num_heads = self.num_heads
      # linear projection
      query = self.linear_q(query)
      key = self.linear_k(key)
      value = self.linear_v(value)
      # split by heads
      query = query.reshape(
          batch_size, -1, num_heads, self.model_dim // self.num_heads
      ).transpose(1, 2)
      key = key.reshape(
          batch_size, -1, num_heads, self.model_dim // self.num_heads
      ).transpose(1, 2)
      value = value.reshape(
          batch_size, -1, num_heads, self.model_dim // self.num_heads
      ).transpose(1, 2)
      # similar_matrix :[B,H,F,F ]
      matrix, _ = self.attention(query, key, value, attn_mask)
  
      return matrix
  
file_path: towhee/towhee/models/transrac/utils.py
imports: from torch import nn
  from towhee.models.layers.attention import Attention
label_desc: Use image node_id 2 for calling the SimilarityMatrix obj's underlying member method code with example usage: obj.forward(query, key, value, attn_mask) and returns: matrix