code: def forward(self, seq, mask):
      in_c = seq.size()[1]
      seq = torch.transpose(seq, 1, 2)  # (N, L, C)
      queries = seq
      keys = seq
      num_heads = self.num_heads
  
      # T_q = T_k = L
      Q = F.relu(self.linear_q(seq))  # (N, T_q, C)
      K = F.relu(self.linear_k(seq))  # (N, T_k, C)
      V = F.relu(self.linear_v(seq))  # (N, T_k, C)
  
      # Split and concat
      Q_ = torch.cat(
          torch.split(Q, in_c // num_heads, dim=2), dim=0
      )  # (h*N, T_q, C/h)
      K_ = torch.cat(
          torch.split(K, in_c // num_heads, dim=2), dim=0
      )  # (h*N, T_k, C/h)
      V_ = torch.cat(
          torch.split(V, in_c // num_heads, dim=2), dim=0
      )  # (h*N, T_k, C/h)
  
      # Multiplication
      outputs = torch.matmul(Q_, K_.transpose(1, 2))  # (h*N, T_q, T_k)
      # Scale
      outputs = outputs / (K_.size()[-1] ** 0.5)
      # Key Masking
      key_masks = mask.repeat(num_heads, 1)  # (h*N, T_k)
      key_masks = torch.unsqueeze(key_masks, 1)  # (h*N, 1, T_k)
      key_masks = key_masks.repeat(
          1, queries.size()[1], 1
      )  # (h*N, T_q, T_k)
  
      paddings = torch.ones_like(outputs) * (
          -INF
      )  # extremely small value
      outputs = torch.where(torch.eq(key_masks, 0), paddings, outputs)
  
      query_masks = mask.repeat(num_heads, 1)  # (h*N, T_q)
      query_masks = torch.unsqueeze(query_masks, -1)  # (h*N, T_q, 1)
      query_masks = query_masks.repeat(
          1, 1, keys.size()[1]
      ).float()  # (h*N, T_q, T_k)
  
      att_scores = (
          F.softmax(outputs, dim=-1) * query_masks
      )  # (h*N, T_q, T_k)
      att_scores = self.dropout(att_scores)
  
      # Weighted sum
      x_outputs = torch.matmul(att_scores, V_)  # (h*N, T_q, C/h)
      # Restore shape
      x_outputs = torch.cat(
          torch.split(
              x_outputs, x_outputs.size()[0] // num_heads, dim=0
          ),
          dim=2,
      )  # (N, T_q, C)
  
      x = torch.transpose(x_outputs, 1, 2)  # (N, C, L)
      x = self.bn(x, mask)
  
      return x
  
imports: import torch
  import torch.nn.functional
  from torch import nn
  from utils import get_length, INF
label_desc: Use image node_id 2 for calling the Attention obj's underlying member method code with example usage: obj.forward(seq, mask) and returns: x