code: def forward(
      model: Model[InT, OutT], Xr: InT, is_train: bool
  ) -> Tuple[OutT, Callable]:
      Q = model.get_param("Q")
      key_transform = model.get_ref(KEY_TRANSFORM_REF)
  
      attention, bp_attention = _get_attention(
          model.ops, Q, key_transform, Xr.dataXd, Xr.lengths, is_train
      )
      output, bp_output = _apply_attention(
          model.ops, attention, Xr.dataXd, Xr.lengths
      )
  
      def backprop(dYr: OutT) -> InT:
          dX, d_attention = bp_output(dYr.dataXd)
          dQ, dX2 = bp_attention(d_attention)
          model.inc_grad("Q", dQ.ravel())
          dX += dX2
          return Ragged(dX, dYr.lengths)
  
      return Ragged(output, Xr.lengths), backprop
  
file_path: thinc/thinc/layers/parametricattention_v2.py
imports: from typing import Callable, Optional, Tuple, cast
  from ..config import registry
  from ..model import Model
  from ..types import Floats2d, Ragged
  from ..util import get_width
  from .noop import noop
label_desc: Use image node_id 2 for calling a global function with example usage: forward(model, Xr, is_train) and returns: Ragged,  backprop, Ragged