code: def test_fit_with_early_stopping_with_validations_per_epoch(self):
      model_args = TransformerModelArguments(
          "sshleifer/tiny-distilroberta-base"
      )
      classifier = TransformerBasedClassification(
          model_args,
          4,
          multi_label=self.multi_label,
          class_weight="balanced",
          num_epochs=2,
          mini_batch_size=5,
          validations_per_epoch=2,
      )
  
      train_set = self._get_dataset(num_samples=10)
      validation_set = self._get_dataset(num_samples=10)
  
      early_stopping = EarlyStopping(Metric("val_loss"))
  
      with mock.patch.object(
          early_stopping,
          "check_early_stop",
          wraps=early_stopping.check_early_stop,
      ) as check_early_stop_spy:
          classifier.fit(
              train_set,
              validation_set=validation_set,
              early_stopping=early_stopping,
          )
          # 2 "intermediate" validations with val_acc/vall_los only + one final one per epoch
          self.assertEqual(6, check_early_stop_spy.call_count)
          for i in range(6):
              self.assertEqual(
                  i // 3 + 1,
                  check_early_stop_spy.call_args_list[i].args[0],
              )
              self.assertTrue(
                  "val_acc"
                  in check_early_stop_spy.call_args_list[i].args[1]
              )
              self.assertTrue(
                  "val_loss"
                  in check_early_stop_spy.call_args_list[i].args[1]
              )
              if (i + 1) % 3 == 0:
                  self.assertTrue(
                      "train_acc"
                      in check_early_stop_spy.call_args_list[i].args[1]
                  )
                  self.assertTrue(
                      "train_loss"
                      in check_early_stop_spy.call_args_list[i].args[1]
                  )
  
imports: import unittest
  import pytest
  import warnings
  import numpy
  from unittest import mock
  from unittest.mock import patch, Mock
  from parameterized import parameterized_class
  from scipy.sparse import issparse
  from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
  from small_text.training.early_stopping import EarlyStopping, NoopEarlyStopping
  from small_text.training.metrics import Metric
  from small_text.training.model_selection import ModelSelection, NoopModelSelection
  from tests.utils.datasets import twenty_news_transformers
  from tests.utils.testing import assert_array_not_equal
label_desc: Use image node_id 13 for calling the _TransformerBasedClassificationTest obj's underlying member method code with example usage: obj.test_fit_with_early_stopping_with_validations_per_epoch() without return types