code: def test_prepare_for_training_text_classification_with_formatting_func(
      feedback_dataset_guidelines: str,
      feedback_dataset_fields: List["AllowedFieldTypes"],
      feedback_dataset_questions: List["AllowedQuestionTypes"],
      feedback_dataset_records: List[FeedbackRecord],
  ):
      dataset = FeedbackDataset(
          guidelines=feedback_dataset_guidelines,
          fields=feedback_dataset_fields,
          questions=feedback_dataset_questions,
      )
      dataset.add_records(records=feedback_dataset_records * 5)
      framework = Framework("setfit")
  
      def wrong_formatting_func(sample):
          text = sample["text"]
          values = [resp["value"] for resp in sample["question-3"]]
          counter = Counter(values)
          if counter:
              most_common = counter.most_common()
              max_frequency = most_common[0][1]
              most_common_elements = [
                  element
                  for element, frequency in most_common
                  if frequency == max_frequency
              ]
              label = random.choice(most_common_elements)
              return {"text": text, "label": label}
          else:
              return None
  
      with pytest.raises(
          ValueError,
          match=re.escape(
              f"formatting_func must return {TextClassificationReturnTypes.__annotations__['format']}, not <class 'list'>"
          ),
      ):
          task = TrainingTask.for_text_classification(
              wrong_formatting_func
          )
          trainer = ArgillaTrainer(
              dataset=dataset, task=task, framework=framework
          )
          trainer.update_config(num_iterations=1)
          train_with_cleanup(trainer, __OUTPUT_DIR__)
  
      def correct_formatting_func(sample):
          data = wrong_formatting_func(sample)
          if data:
              yield (data["text"], data["label"])
          else:
              yield None
  
      task = TrainingTask.for_text_classification(
          correct_formatting_func
      )
      trainer = ArgillaTrainer(
          dataset=dataset, task=task, framework=framework
      )
      trainer.update_config(num_iterations=1)
      train_with_cleanup(trainer, __OUTPUT_DIR__)
  
      def correct_formatting_func_with_yield(sample):
          data = wrong_formatting_func(sample)
          if data:
              yield (data["text"], data["label"])
          else:
              yield None
  
      task = TrainingTask.for_text_classification(
          correct_formatting_func_with_yield
      )
      trainer = ArgillaTrainer(
          dataset=dataset, task=task, framework=framework
      )
      trainer.update_config(num_iterations=1)
      train_with_cleanup(trainer, __OUTPUT_DIR__)
  
imports: import random
  from collections import Counter
  from typing import TYPE_CHECKING, Callable, List, Union
  import pytest
  import re
  import shutil
  import sys
  from pathlib import Path
  from argilla.client.feedback.dataset import FeedbackDataset
  from argilla.client.feedback.schemas import FeedbackRecord, LabelQuestion, MultiLabelQuestion
  from argilla.client.feedback.schemas.enums import ResponseStatusFilter
  from argilla.client.feedback.schemas.records import SortBy
  from argilla.client.feedback.training import ArgillaTrainer
  from argilla.client.feedback.training.schemas.base import TrainingTask, TrainingTaskForTextClassification, TrainingTaskMapping, TrainingTaskMappingForTextClassification, TrainingTaskTypes
  from argilla.client.feedback.training.schemas.return_types import QuestionAnsweringReturnTypes, TextClassificationReturnTypes
  from argilla.client.feedback.unification import LabelQuestionUnification
  from argilla.client.models import Framework
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
  from tests.integration.training.helpers import train_with_cleanup
label_desc: Use image node_id 3 for calling a global function with example usage: test_prepare_for_training_text_classification_with_formatting_func(feedback_dataset_guidelines, feedback_dataset_fields, feedback_dataset_questions, feedback_dataset_records) and returns: dict, None