code: def efficient_causal_attention_parallel(x, y, z):
      """
      efficient causal attention operation
      Args:
          x (Tensor): Tensor with shape `(batch, n, d1)`
          y (Tensor): Tensor with shape `(batch, n, d1)`
          z (Tensor): Tensor with shape '(batch, n, d2)`
      return:
      """
      bsz, n, d1 = x.size()
      # (bsz, n, d1, 1) x (bsz, n, 1, d2) -> (bsz, n, d1, d2)
      sum_mat = torch.matmul(y.unsqueeze(3), z.unsqueeze(2))
      accum_mat = torch.cumsum(sum_mat, dim=1)
      # (bsz, n, 1, d1) x (bsz, n, d1, d2) -> (bsz, n, 1, d2) -> (bsz, n, d2)
      res = torch.matmul(x.unsqueeze(2), accum_mat).squeeze(2)
      # (1, n, 1)
      length_div = (
          torch.arange(1, n + 1, device=x.device)
          .unsqueeze(0)
          .unsqueeze(2)
      )
      res = res / length_div
      return res
  
imports: import math
  from typing import Dict, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from fairseq import utils
  from fairseq.incremental_decoding_utils import with_incremental_state
  from fairseq.modules.fairseq_dropout import FairseqDropout
  from torch import nn, Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: efficient_causal_attention_parallel(x, y, z) and returns: res