class_docstr: Multi-Head Attention implementation from https://arxiv.org/abs/1706.03762
  used for Movie+MCAN
class_docstr_tok: ["Multi-Head","Attention","implementation","from","https",":","\/\/arxiv.org\/abs\/1706.03762","used","for","Movie+MCAN"]
code: def forward(
      self,
      q: torch.Tensor,
      k: torch.Tensor,
      v: torch.Tensor,
      mask: torch.Tensor,
  ) -> torch.Tensor:
      b = q.size(0)
  
      q = (
          self.linears[0](q)
          .view(b, -1, self.h, self.d_k)
          .transpose(1, 2)
      )
      k = (
          self.linears[1](k)
          .view(b, -1, self.h, self.d_k)
          .transpose(1, 2)
      )
      v = (
          self.linears[2](v)
          .view(b, -1, self.h, self.d_k)
          .transpose(1, 2)
      )
  
      x, self.p_attn = self.qkv_attention(
          q, k, v, mask=mask, dropout=self.dropout
      )
      x = x.transpose(1, 2).contiguous().view(b, -1, self.h * self.d_k)
  
      return self.linears[-1](x)
  
imports: import math
  from typing import Optional, Tuple, Type
  import torch
  from mmf.modules.layers import GatedTanh, ModalCombineLayer, TransformLayer
  from torch import nn
label_desc: Use image node_id 3 for calling the MovieMcanMultiHeadAttention obj's underlying member method code with example usage: obj.forward(q, k, v, mask) and returns: self