code: def test_weighted_f1(simple_confusion, short_confusion):
      assert confusion_to_weighted_f1(
          simple_confusion
      ) == pytest.approx(0.83333333)
      assert confusion_to_weighted_f1(short_confusion) == pytest.approx(
          0.66666666
      )
  
      assert confusion_to_weighted_f1(
          simple_confusion, exclude=["O"]
      ) == pytest.approx(0.66666666)
      assert confusion_to_weighted_f1(
          short_confusion, exclude=["O"]
      ) == pytest.approx(0.33333333)
  
file_path: stanza/stanza/tests/common/test_confusion.py
imports: from collections import defaultdict
  import pytest
  from stanza.utils.confusion import format_confusion, confusion_to_f1, confusion_to_macro_f1, confusion_to_weighted_f1
label_desc: Use image node_id 7 for calling a global function with example usage: test_weighted_f1(simple_confusion, short_confusion) without return types