class_docstr: Single-head Attention layer for label-specific representations
class_docstr_tok: ["Single-head","Attention","layer","for","label-specific","representations"]
code: def combine_v(self, outputs):
      # Combine attention information from the different labels
      d_l = self.d_l
      outputs = outputs.view(d_l, -1, self.d_v)  # d_l x len_inp x d_v
  
      if not self.partitioned:
          # Switch from d_l x len_inp x d_v to len_inp x d_l x d_v
          if self.combine_as_self:
              outputs = (
                  torch.transpose(outputs, 0, 1)
                  .contiguous()
                  .view(-1, d_l * self.d_v)
              )
          else:
              outputs = torch.transpose(
                  outputs, 0, 1
              )  # .contiguous() #.view(-1, d_l * self.d_v)
          # Project back to residual size
          outputs = self.proj(
              outputs
          )  # Becomes len_inp x d_l x d_model
      else:
          d_v1 = self.d_v // 2
          outputs1 = outputs[:, :, :d_v1]
          outputs2 = outputs[:, :, d_v1:]
          if self.combine_as_self:
              outputs1 = (
                  torch.transpose(outputs1, 0, 1)
                  .contiguous()
                  .view(-1, d_l * d_v1)
              )
              outputs2 = (
                  torch.transpose(outputs2, 0, 1)
                  .contiguous()
                  .view(-1, d_l * d_v1)
              )
          else:
              outputs1 = torch.transpose(
                  outputs1, 0, 1
              )  # .contiguous() #.view(-1, d_l * d_v1)
              outputs2 = torch.transpose(
                  outputs2, 0, 1
              )  # .contiguous() #.view(-1, d_l * d_v1)
          outputs = torch.cat(
              [
                  self.proj1(outputs1),
                  self.proj2(outputs2),
              ],
              -1,
          )  # .contiguous()
  
      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 LabelAttention obj's underlying member method code with example usage: obj.combine_v(outputs) and returns: outputs