class_docstr: based on allennlp.training.metrics.AttachmentScores
  Computes labeled and unlabeled attachment scores for a dependency parse. Note that the input
  to this metric is the sampled predictions, not the distribution itself.
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``.
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","``","."]
code: def add(
      self,
      gold_indices: torch.Tensor,
      gold_labels: torch.Tensor,
      predicted_indices: torch.Tensor,
      predicted_labels: torch.Tensor,
  ):
      """
      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``.
      """
      unwrapped = self.unpack(
          predicted_indices, predicted_labels, gold_indices, gold_labels
      )
      (
          predicted_indices,
          predicted_labels,
          gold_indices,
          gold_labels,
      ) = unwrapped
  
      predicted_indices = predicted_indices.long()
      predicted_labels = predicted_labels.long()
      gold_indices = gold_indices.long()
      gold_labels = gold_labels.long()
  
      correct_indices = predicted_indices.eq(gold_indices).long()
      correct_labels = predicted_labels.eq(gold_labels).long()
      correct_labels_and_indices = correct_indices * correct_labels
  
      self._unlabeled_correct += correct_indices.sum().item()
      self._labeled_correct += correct_labels_and_indices.sum().item()
      self._total_words += correct_indices.numel()
  
imports: import collections
  import logging
  import os
  from dataclasses import dataclass, field
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch.utils.data import DataLoader
  from torch.utils.data.dataset import Dataset
  from tqdm import tqdm
  from adapters import AdapterTrainer
  from transformers import DataCollator, EvalPrediction, PreTrainedModel, PreTrainedTokenizerBase, Trainer, TrainerCallback, TrainingArguments, is_torch_tpu_available
  from transformers.trainer_utils import PredictionOutput
label_desc: Use image node_id 2 for calling the ParsingMetric obj's underlying member method code with example usage: obj.add(gold_indices, gold_labels, predicted_indices, predicted_labels) without return types