code: def forward(self, x, mask=None):
      if isinstance(x, tuple):
          x_c, x_p = x
      else:
          x_c, x_p = torch.chunk(x, 2, dim=-1)
      qkv_c = torch.einsum("btf,hfca->bhtca", x_c, self.w_qkv_c)
      qkv_p = torch.einsum("btf,hfca->bhtca", x_p, self.w_qkv_p)
      q_c, k_c, v_c = [
          c.squeeze(dim=3) for c in torch.chunk(qkv_c, 3, dim=3)
      ]
      q_p, k_p, v_p = [
          c.squeeze(dim=3) for c in torch.chunk(qkv_p, 3, dim=3)
      ]
      q = torch.cat([q_c, q_p], dim=-1) * self.scaling_factor
      k = torch.cat([k_c, k_p], dim=-1)
      v = torch.cat([v_c, v_p], dim=-1)
      dots = torch.einsum("bhqa,bhka->bhqk", q, k)
      if mask is not None:
          dots.data.masked_fill_(~mask[:, None, None, :], -float("inf"))
      probs = F.softmax(dots, dim=-1)
      probs = self.dropout(probs)
      o = torch.einsum("bhqk,bhka->bhqa", probs, v)
      o_c, o_p = torch.chunk(o, 2, dim=-1)
      out_c = torch.einsum("bhta,haf->btf", o_c, self.w_o_c)
      out_p = torch.einsum("bhta,haf->btf", o_p, self.w_o_p)
      return out_c, out_p
  
imports: import copy
  import math
  import torch
  import torch.nn
  import torch.nn.functional
  from stanza.models.constituency.positional_encoding import ConcatSinusoidalEncoding
label_desc: Use image node_id 2 for calling the PartitionedMultiHeadAttention obj's underlying member method code with example usage: obj.forward(x, mask) and returns: out_c,  out_p