code: def forward(self, query_inputs, key_inputs, attention_mask):
      extended_attention_mask = (1.0 - attention_mask) * -10000.0
      assert extended_attention_mask.dim() == 2
      extended_attention_mask = extended_attention_mask.unsqueeze(1)
  
      query_layer = self.query(query_inputs)
      if query_layer.dim() == 2:
          query_layer = query_layer.unsqueeze(1)
          squeeze_result = True
      else:
          squeeze_result = False
      key_layer = self.key(key_inputs)
  
      scores = torch.matmul(query_layer, key_layer.transpose(-1, -2))
      scores = scores / math.sqrt(self.query_key_size)
      scores = scores + extended_attention_mask
      if squeeze_result:
          scores = scores.squeeze(1)
  
      return scores
  
imports: import functools
  import logging
  import math
  import torch
  import torch.nn.functional
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.modules.layers import ClassifierLayer
  from mmf.utils.build import build_image_encoder
  from omegaconf import OmegaConf
  from torch import nn
label_desc: Use image node_id 2 for calling the OcrPtrNet obj's underlying member method code with example usage: obj.forward(query_inputs, key_inputs, attention_mask) and returns: scores