class_docstr: Biaffine layer for first-order scoring.
  
  This function has a tensor of weights :math:`W` and bias terms if needed.
  The score :math:`s(x, y)` of the vector pair :math:`(x, y)` is computed as :math:`x^T W y`,
  in which :math:`x` and :math:`y` can be concatenated with bias terms.
  
  References:
      - Timothy Dozat and Christopher D. Manning. 2017.
        `Deep Biaffine Attention for Neural Dependency Parsing`_.
  
  Args:
      n_in (int):
          The size of the input feature.
      n_out (int):
          The number of output channels.
      bias_x (bool):
          If ``True``, adds a bias term for tensor :math:`x`. Default: ``True``.
      bias_y (bool):
          If ``True``, adds a bias term for tensor :math:`y`. Default: ``True``.
  
  .. _Deep Biaffine Attention for Neural Dependency Parsing:
      https://openreview.net/forum?id=Hk95PK9le
class_docstr_tok: ["Biaffine","layer","for","first-order","scoring",".","This","function","has","a","tensor","of","weights",":","math",":","`","W","`","and","bias","terms","if","needed",".","The","score",":","math",":","`","s","(","x",",","y",")","`","of","the","vector","pair",":","math",":","`","(","x",",","y",")","`","is","computed","as",":","math",":","`","x^T","W","y","`",",","in","which",":","math",":","`","x","`","and",":","math",":","`","y","`","can","be","concatenated","with","bias","terms",".","References",":","-","Timothy","Dozat","and","Christopher","D.","Manning",".","2017",".","`","Deep","Biaffine","Attention","for","Neural","Dependency","Parsing","`","_",".","Args",":","n_in","(","int",")",":","The","size","of","the","input","feature",".","n_out","(","int",")",":","The","number","of","output","channels",".","bias_x","(","bool",")",":","If","``","True","``",",","adds","a","bias","term","for","tensor",":","math",":","`","x","`",".","Default",":","``","True","``",".","bias_y","(","bool",")",":","If","``","True","``",",","adds","a","bias","term","for","tensor",":","math",":","`","y","`",".","Default",":","``","True","``",".","..","_Deep","Biaffine","Attention","for","Neural","Dependency","Parsing",":","https",":","\/\/openreview.net\/forum","?","id=Hk95PK9le"]
docstr: Args:
      x (torch.Tensor): ``[batch_size, seq_len, n_in]``.
      y (torch.Tensor): ``[batch_size, seq_len, n_in]``.
  
  Returns:
      ~torch.Tensor:
          A scoring tensor of shape ``[batch_size, n_out, seq_len, seq_len]``.
          If ``n_out=1``, the dimension for ``n_out`` will be squeezed automatically.
docstr_tok: ["Args",":","x","(","torch.Tensor",")",":","``","[","batch_size",",","seq_len",",","n_in","]","``",".","y","(","torch.Tensor",")",":","``","[","batch_size",",","seq_len",",","n_in","]","``",".","Returns",":","~torch.Tensor",":","A","scoring","tensor","of","shape","``","[","batch_size",",","n_out",",","seq_len",",","seq_len","]","``",".","If","``","n_out=1","``",",","the","dimension","for","``","n_out","``","will","be","squeezed","automatically","."]
code: def forward(self, x, y):
      r"""
      Args:
          x (torch.Tensor): ``[batch_size, seq_len, n_in]``.
          y (torch.Tensor): ``[batch_size, seq_len, n_in]``.
  
      Returns:
          ~torch.Tensor:
              A scoring tensor of shape ``[batch_size, n_out, seq_len, seq_len]``.
              If ``n_out=1``, the dimension for ``n_out`` will be squeezed automatically.
      """
  
      if self.bias_x:
          x = torch.cat((x, torch.ones_like(x[..., :1])), -1)
      if self.bias_y:
          y = torch.cat((y, torch.ones_like(y[..., :1])), -1)
      # [batch_size, n_out, seq_len, seq_len]
      s = torch.einsum("bxi,oij,byj->boxy", x, self.weight, y)
      # remove dim 1 if n_out == 1
      s = s.squeeze(1)
  
      return s
  
imports: import torch
  import torch.nn
  from torch.nn.utils.rnn import pack_padded_sequence, PackedSequence
  from torch.nn.modules.rnn import apply_permutation
label_desc: Use image node_id 4 for calling the Biaffine obj's underlying member method code with example usage: obj.forward(x, y) and returns: s