class_docstr: This `Metric` calculates the unbiased sample covariance between two tensors.
  Each element in the two tensors is assumed to be a different observation of the
  variable (i.e., the input tensors are implicitly flattened into vectors and the
  covariance is calculated between the vectors).
  
  This implementation is mostly modeled after the streaming_covariance function in Tensorflow. See:
  <https://github.com/tensorflow/tensorflow/blob/v1.10.1/tensorflow/contrib/metrics/python/ops/metric_ops.py#L3127>
  
  The following is copied from the Tensorflow documentation:
  
  The algorithm used for this online computation is described in
  <https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online>.
  Specifically, the formula used to combine two sample comoments is
  `C_AB = C_A + C_B + (E[x_A] - E[x_B]) * (E[y_A] - E[y_B]) * n_A * n_B / n_AB`
  The comoment for a single batch of data is simply `sum((x - E[x]) * (y - E[y]))`, optionally masked.
code: def __init__(self) -> None:
      self._total_prediction_mean = 0.0
      self._total_label_mean = 0.0
      self._total_co_moment = 0.0
      self._total_count = 0.0
  
file_path: allennlp/allennlp/training/metrics/covariance.py
imports: import logging
  from typing import Optional
  import torch
  from allennlp.common.util import is_distributed
  from allennlp.training.metrics.metric import Metric
label_desc: Use image node_id 1 to create a new Covariance object from inherited base classes: Metric with example: obj = Covariance()