code: def gen_test_supervised_util_test(self, kwargs):
      def check(data):
          third = int(len(data) / 3)
          train_data = data[: 2 * third]
          valid_data = data[third:]
          with tempfile.NamedTemporaryFile(
              delete=False
          ) as tmpf, tempfile.NamedTemporaryFile(delete=False) as tmpf2:
              for line in train_data:
                  tmpf.write(
                      ("__label__" + line.strip() + "\n").encode(
                          "UTF-8"
                      )
                  )
              tmpf.flush()
              for line in valid_data:
                  tmpf2.write(
                      ("__label__" + line.strip() + "\n").encode(
                          "UTF-8"
                      )
                  )
              tmpf2.flush()
              model = train_supervised(input=tmpf.name, **kwargs)
              true_labels = []
              all_words = []
              with open(tmpf2.name, "r") as fid:
                  for line in fid:
                      if sys.version_info < (3, 0):
                          line = line.decode("UTF-8")
                      if len(line.strip()) == 0:
                          continue
                      words, labels = model.get_line(line.strip())
                      if len(labels) == 0:
                          continue
                      all_words.append(" ".join(words))
                      true_labels += [labels]
              predictions, _ = model.predict(all_words)
              p, r = util.test(predictions, true_labels)
              N = len(predictions)
              Nt, pt, rt = model.test(tmpf2.name)
              self.assertEqual(N, Nt)
              self.assertEqual(p, pt)
              self.assertEqual(r, rt)
  
      # Need at least one word to have a label and a word to prevent error
      check(get_random_data(100, min_words_line=2))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from fasttext import train_supervised
  from fasttext import train_unsupervised
  from fasttext import util
  import fasttext
  import os
  import subprocess
  import unittest
  import tempfile
  import random
  import sys
  import copy
  import numpy
  from fasttext.tests.test_configurations import get_supervised_models
label_desc: Use image node_id 3 for calling the TestFastTextUnitPy obj's underlying member method code with example usage: obj.gen_test_supervised_util_test(kwargs) without return types