code: def test_random(self):
      accuracy = Accuracy(
          metrics=["accuracy", "precision", "recall", "F1"]
      )
      for _ in tqdm.tqdm(range(100)):
          length = random.randint(2, 1000000)
          n_labels = random.randint(2, 100000)
          ground_truth = []
          predict = []
          for _ in range(length):
              ground_truth.append(random.randint(0, n_labels - 1))
              predict.append(random.randint(0, n_labels - 1))
          ground_truth = np.array(ground_truth)
          predict = np.array(predict)
          average = random.choice(["weighted", "macro", "micro"])
          accuracy_sklearn = metrics.accuracy_score(
              y_true=ground_truth, y_pred=predict
          )
          (
              precision_sklearn,
              recall_sklearn,
              f1_sklearn,
              _,
          ) = metrics.precision_recall_fscore_support(
              y_true=ground_truth, y_pred=predict, average=average
          )
  
          (
              accuracy_graph4ai,
              precision_graph4ai,
              recall_graph4ai,
              f1_graph4ai,
          ) = accuracy.calculate_scores(
              ground_truth=torch.from_numpy(ground_truth),
              predict=torch.from_numpy(predict),
              average=average,
          )
          self.assertEqual(precision_graph4ai, precision_sklearn)
          self.assertEqual(recall_graph4ai, recall_sklearn)
          self.assertEqual(f1_graph4ai, f1_sklearn)
          self.assertEqual(accuracy_graph4ai, accuracy_sklearn)
      print("random test 1 passed")
  
      for _ in tqdm.tqdm(range(100)):
          length = random.randint(2, 1000000)
          n_labels = random.randint(2, 100000)
          replace_ratio = random.random() / 1.5
          ground_truth = []
          predict = []
          for _ in range(length):
              ground_truth.append(random.randint(0, n_labels - 1))
              if random.random() < replace_ratio:
                  predict.append(random.randint(0, n_labels - 1))
              else:
                  predict.append(ground_truth[-1])
          ground_truth = np.array(ground_truth)
          predict = np.array(predict)
          average = random.choice(["weighted", "macro", "micro"])
          accuracy_sklearn = metrics.accuracy_score(
              y_true=ground_truth, y_pred=predict
          )
          (
              precision_sklearn,
              recall_sklearn,
              f1_sklearn,
              _,
          ) = metrics.precision_recall_fscore_support(
              y_true=ground_truth, y_pred=predict, average=average
          )
  
          (
              accuracy_graph4ai,
              precision_graph4ai,
              recall_graph4ai,
              f1_graph4ai,
          ) = accuracy.calculate_scores(
              ground_truth=torch.from_numpy(ground_truth),
              predict=torch.from_numpy(predict),
              average=average,
          )
          self.assertEqual(precision_graph4ai, precision_sklearn)
          self.assertEqual(recall_graph4ai, recall_sklearn)
          self.assertEqual(f1_graph4ai, f1_sklearn)
          self.assertEqual(accuracy_graph4ai, accuracy_sklearn)
      print("random test 2 passed")
  
file_path: graph4nlp/graph4nlp/pytorch/test/evaluation/test_accuracy.py
imports: import random
  import unittest
  import numpy
  import torch
  import tqdm
  from sklearn import metrics
  from graph4nlp.pytorch.modules.evaluation.accuracy import Accuracy
label_desc: Use image node_id 2 for calling the MyTestCase obj's underlying member method code with example usage: obj.test_random() without return types