code: def _cal_fweight(self, f, shape):
      f_theta, f_phi, f_g = f
      # flatten
      f_theta = paddle.transpose(f_theta, [0, 2, 3, 1])
      f_theta = paddle.reshape(
          f_theta, [shape[0] * shape[1], shape[2], 128]
      )
      f_phi = paddle.transpose(f_phi, [0, 2, 3, 1])
      f_phi = paddle.reshape(
          f_phi, [shape[0] * shape[1], shape[2], 128]
      )
      f_g = paddle.transpose(f_g, [0, 2, 3, 1])
      f_g = paddle.reshape(f_g, [shape[0] * shape[1], shape[2], 128])
      # correlation
      f_attn = paddle.matmul(
          f_theta, paddle.transpose(f_phi, [0, 2, 1])
      )
      # scale
      f_attn = f_attn / (128**0.5)
      f_attn = F.softmax(f_attn)
      # weighted sum
      f_weight = paddle.matmul(f_attn, f_g)
      f_weight = paddle.reshape(
          f_weight, [shape[0], shape[1], shape[2], 128]
      )
      return f_weight
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import nn
  import paddle.nn.functional
  from paddle import ParamAttr
label_desc: Use image node_id 2 for calling the Cross_Attention obj's underlying member method code with example usage: obj._cal_fweight(f, shape) and returns: f_weight