class_docstr: Multi-head attention module
class_docstr_tok: ["Multi-head","attention","module"]
code: def combine_v(self, outputs):
      # Combine attention information from the different heads
      n_head = self.n_head
      outputs = outputs.view(
          n_head, -1, self.d_v
      )  # n_head x len_inp x d_kv
  
      if not self.partitioned:
          # Switch from n_head x len_inp x d_v to len_inp x (n_head * d_v)
          outputs = (
              torch.transpose(outputs, 0, 1)
              .contiguous()
              .view(-1, n_head * self.d_v)
          )
  
          # Project back to residual size
          outputs = self.proj(outputs)
      else:
          d_v1 = self.d_v // 2
          outputs1 = outputs[:, :, :d_v1]
          outputs2 = outputs[:, :, d_v1:]
          outputs1 = (
              torch.transpose(outputs1, 0, 1)
              .contiguous()
              .view(-1, n_head * d_v1)
          )
          outputs2 = (
              torch.transpose(outputs2, 0, 1)
              .contiguous()
              .view(-1, n_head * d_v1)
          )
          outputs = torch.cat(
              [
                  self.proj1(outputs1),
                  self.proj2(outputs2),
              ],
              -1,
          )
  
      return outputs
  
imports: import numpy
  import functools
  import sys
  import torch
  from torch.autograd import Variable
  import torch.nn
  import torch.nn.init
label_desc: Use image node_id 4 for calling the MultiHeadAttention obj's underlying member method code with example usage: obj.combine_v(outputs) and returns: outputs