code: def test_f1_multi_class_score(self):
      # Arrange
      t, p = _generate_classes_and_scores(
          3, n=100, hard_predictions=True
      )
      targets = turicreate.SArray(t)
      predictions = turicreate.SArray(p)
      str_targets = targets.astype(str)
      str_predictions = predictions.astype(str)
  
      # Act
      skl_score = f1_score(
          list(targets), list(predictions), average="macro"
      )
      score = turicreate.toolkits.evaluation.f1_score(
          targets, predictions
      )
      str_score = turicreate.toolkits.evaluation.f1_score(
          str_targets, str_predictions
      )
  
      # Assert
      self.assertAlmostEqual(skl_score, score)
      self.assertAlmostEqual(skl_score, str_score)
  
      # Act [Average = 'macro']
      skl_score = f1_score(
          list(targets), list(predictions), average="macro"
      )
      score = turicreate.toolkits.evaluation.f1_score(
          targets, predictions, average="macro"
      )
      str_score = turicreate.toolkits.evaluation.f1_score(
          str_targets, str_predictions, average="macro"
      )
  
      # Assert
      self.assertAlmostEqual(skl_score, score)
      self.assertAlmostEqual(skl_score, str_score)
  
      # Act [Average = 'micro']
      skl_score = f1_score(
          list(targets), list(predictions), average="micro"
      )
      score = turicreate.toolkits.evaluation.f1_score(
          targets, predictions, average="micro"
      )
      str_score = turicreate.toolkits.evaluation.f1_score(
          str_targets, str_predictions, average="micro"
      )
  
      # Assert
      self.assertAlmostEqual(skl_score, score)
      self.assertAlmostEqual(skl_score, str_score)
  
      # Act [Average = None]
      skl_score = f1_score(
          list(targets), list(predictions), average=None
      )
      score = turicreate.toolkits.evaluation.f1_score(
          targets, predictions, average=None
      )
      str_score = turicreate.toolkits.evaluation.f1_score(
          str_targets, str_predictions, average=None
      )
      # Assert
      self.assertEqual(type(score), dict)
      self.assertEqual(set(score.keys()), set([0, 1, 2]))
      self.assertEqual(set(str_score.keys()), set(["0", "1", "2"]))
  
      # Note: Explicitly not putting it into a for loop for ease of
      # debugging when the tests fail.
      self.assertAlmostEqual(skl_score[0], score[0])
      self.assertAlmostEqual(skl_score[0], str_score["0"])
      self.assertAlmostEqual(skl_score[1], score[1])
      self.assertAlmostEqual(skl_score[1], str_score["1"])
      self.assertAlmostEqual(skl_score[2], score[2])
      self.assertAlmostEqual(skl_score[2], str_score["2"])
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import unittest
  import turicreate
  from turicreate.toolkits._main import ToolkitError
  import math
  from numpy import inf
  import numpy
label_desc: Use image node_id 16 for calling the MetricsTest obj's underlying member method code with example usage: obj.test_f1_multi_class_score() without return types