class_docstr: Computes labeled and unlabeled attachment scores for a
  dependency parse, as well as sentence level exact match
  for both labeled and unlabeled trees. Note that the input
  to this metric is the sampled predictions, not the distribution
  itself.
  
  Parameters
  ----------
  ignore_classes : ``List[int]``, optional (default = None)
      A list of label ids to ignore when computing metrics.
docstr: Parameters
  ----------
  predicted_indices : ``torch.Tensor``, required.
      A tensor of head index predictions of shape (batch_size, timesteps).
  predicted_labels : ``torch.Tensor``, required.
      A tensor of arc label predictions of shape (batch_size, timesteps).
  gold_indices : ``torch.Tensor``, required.
      A tensor of the same shape as ``predicted_indices``.
  gold_labels : ``torch.Tensor``, required.
      A tensor of the same shape as ``predicted_labels``.
  mask: ``torch.Tensor``, optional (default = None).
      A tensor of the same shape as ``predicted_indices``.
docstr_tok: ["Parameters","--","--","--","--","--","predicted_indices",":","``","torch.Tensor","``",",","required",".","A","tensor","of","head","index","predictions","of","shape","(","batch_size",",","timesteps",")",".","predicted_labels",":","``","torch.Tensor","``",",","required",".","A","tensor","of","arc","label","predictions","of","shape","(","batch_size",",","timesteps",")",".","gold_indices",":","``","torch.Tensor","``",",","required",".","A","tensor","of","the","same","shape","as","``","predicted_indices","``",".","gold_labels",":","``","torch.Tensor","``",",","required",".","A","tensor","of","the","same","shape","as","``","predicted_labels","``",".","mask",":","``","torch.Tensor","``",",","optional","(","default","=","None",")",".","A","tensor","of","the","same","shape","as","``","predicted_indices","``","."]
code: def __call__(
      self,  # type: ignore
      predicted_indices,
      predicted_labels,
      gold_indices,
      gold_labels,
      mask=None,
  ):
      """
      Parameters
      ----------
      predicted_indices : ``torch.Tensor``, required.
          A tensor of head index predictions of shape (batch_size, timesteps).
      predicted_labels : ``torch.Tensor``, required.
          A tensor of arc label predictions of shape (batch_size, timesteps).
      gold_indices : ``torch.Tensor``, required.
          A tensor of the same shape as ``predicted_indices``.
      gold_labels : ``torch.Tensor``, required.
          A tensor of the same shape as ``predicted_labels``.
      mask: ``torch.Tensor``, optional (default = None).
          A tensor of the same shape as ``predicted_indices``.
      """
      unwrapped = self.unwrap_to_tensors(
          predicted_indices,
          predicted_labels,
          gold_indices,
          gold_labels,
          mask,
      )
      (
          predicted_indices,
          predicted_labels,
          gold_indices,
          gold_labels,
          mask,
      ) = unwrapped
  
      mask = mask.long()
      predicted_indices = predicted_indices.long()
      predicted_labels = predicted_labels.long()
      gold_indices = gold_indices.long()
      gold_labels = gold_labels.long()
  
      # Multiply by a mask donoting locations of
      # gold labels which we should ignore.
      for label in self._ignore_classes:
          label_mask = gold_labels.eq(label)
          mask = mask * (1 - label_mask).long()
  
      correct_indices = predicted_indices.eq(gold_indices).long() * mask
      unlabeled_exact_match = (correct_indices + (1 - mask)).prod(
          dim=-1
      )
      correct_labels = predicted_labels.eq(gold_labels).long() * mask
      correct_labels_and_indices = correct_indices * correct_labels
      labeled_exact_match = (
          correct_labels_and_indices + (1 - mask)
      ).prod(dim=-1)
  
      self._unlabeled_correct += correct_indices.sum()
      self._exact_unlabeled_correct += unlabeled_exact_match.sum()
      self._labeled_correct += correct_labels_and_indices.sum()
      self._exact_labeled_correct += labeled_exact_match.sum()
      self._total_sentences += correct_indices.size(0)
      self._total_words += correct_indices.numel() - (1 - mask).sum()
  
file_path: magnitude/pymagnitude/third_party/allennlp/training/metrics/attachment_scores.py
imports: from __future__ import division
  from __future__ import absolute_import
  import torch
  from allennlp.training.metrics.metric import Metric
label_desc: Use image node_id 2 for calling the AttachmentScores obj's underlying member method code with example usage: obj.__call__(predicted_indices, predicted_labels, gold_indices, gold_labels, mask) without return types