docstr: Prepares the dataset for training for a specific training framework and NLP task by splitting the dataset into train and test sets.
  
  Args:
      framework: the framework to use for training. Currently supported frameworks are: `transformers`, `peft`,
          `setfit`, `spacy`, `spacy-transformers`, `span_marker`, `spark-nlp`, `openai`, `trl`, `sentence-transformers`.
      task: the NLP task to use for training. Currently supported tasks are: `TrainingTaskForTextClassification`,
          `TrainingTaskForSFT`, `TrainingTaskForRM`, `TrainingTaskForPPO`, `TrainingTaskForDPO`, `TrainingTaskForSentenceSimilarity`.
      train_size: the size of the train set. If `None`, the whole dataset will be used for training.
      test_size: the size of the test set. If `None`, the whole dataset will be used for testing.
      seed: the seed to use for splitting the dataset into train and test sets.
      lang: the spaCy language to use for training. If `None`, the language of the dataset will be used.
docstr_tok: ["Prepares","the","dataset","for","training","for","a","specific","training","framework","and","NLP","task","by","splitting","the","dataset","into","train","and","test","sets",".","Args",":","framework",":","the","framework","to","use","for","training",".","Currently","supported","frameworks","are",":","`","transformers","`",",","`","peft","`",",","`","setfit","`",",","`","spacy","`",",","`","spacy-transformers","`",",","`","span_marker","`",",","`","spark-nlp","`",",","`","openai","`",",","`","trl","`",",","`","sentence-transformers","`",".","task",":","the","NLP","task","to","use","for","training",".","Currently","supported","tasks","are",":","`","TrainingTaskForTextClassification","`",",","`","TrainingTaskForSFT","`",",","`","TrainingTaskForRM","`",",","`","TrainingTaskForPPO","`",",","`","TrainingTaskForDPO","`",",","`","TrainingTaskForSentenceSimilarity","`",".","train_size",":","the","size","of","the","train","set",".","If","`","None","`",",","the","whole","dataset","will","be","used","for","training",".","test_size",":","the","size","of","the","test","set",".","If","`","None","`",",","the","whole","dataset","will","be","used","for","testing",".","seed",":","the","seed","to","use","for","splitting","the","dataset","into","train","and","test","sets",".","lang",":","the","spaCy","language","to","use","for","training",".","If","`","None","`",",","the","language","of","the","dataset","will","be","used","."]
code: def prepare_for_training(
      self,
      framework: Union[Framework, str],
      task: TrainingTaskTypes,
      train_size: Optional[float] = 1,
      test_size: Optional[float] = None,
      seed: Optional[int] = None,
      lang: Optional[str] = None,
  ) -> Any:
      """
      Prepares the dataset for training for a specific training framework and NLP task by splitting the dataset into train and test sets.
  
      Args:
          framework: the framework to use for training. Currently supported frameworks are: `transformers`, `peft`,
              `setfit`, `spacy`, `spacy-transformers`, `span_marker`, `spark-nlp`, `openai`, `trl`, `sentence-transformers`.
          task: the NLP task to use for training. Currently supported tasks are: `TrainingTaskForTextClassification`,
              `TrainingTaskForSFT`, `TrainingTaskForRM`, `TrainingTaskForPPO`, `TrainingTaskForDPO`, `TrainingTaskForSentenceSimilarity`.
          train_size: the size of the train set. If `None`, the whole dataset will be used for training.
          test_size: the size of the test set. If `None`, the whole dataset will be used for testing.
          seed: the seed to use for splitting the dataset into train and test sets.
          lang: the spaCy language to use for training. If `None`, the language of the dataset will be used.
      """
      if isinstance(framework, str):
          framework = Framework(framework)
  
      # validate train and test sizes
      if train_size is None:
          train_size = 1
      if test_size is None:
          test_size = 1 - train_size
  
      # check if all numbers are larger than 0
      if not [abs(train_size), abs(test_size)] == [
          train_size,
          test_size,
      ]:
          raise ValueError(
              "`train_size` and `test_size` must be larger than 0."
          )
      # check if train sizes sum up to 1
      if not (train_size + test_size) == 1:
          raise ValueError(
              "`train_size` and `test_size` must sum to 1."
          )
  
      if test_size == 0:
          test_size = None
  
      if len(self.records) < 1:
          raise ValueError(
              "No records found in the dataset. Make sure you add records to the"
              " dataset via the `FeedbackDataset.add_records()` method first."
          )
  
      local_dataset = self
      if isinstance(
          task,
          (
              TrainingTaskForTextClassification,
              TrainingTaskForSentenceSimilarity,
          ),
      ):
          if task.formatting_func is None:
              # in sentence-transformer models we can train without labels
              if task.label:
                  local_dataset = (
                      local_dataset.compute_unified_responses(
                          question=task.label.question,
                          strategy=task.label.strategy,
                      )
                  )
      elif isinstance(task, TrainingTaskForQuestionAnswering):
          if task.formatting_func is None:
              local_dataset = self.compute_unified_responses(
                  question=task.answer.name, strategy="disagreement"
              )
      elif not isinstance(
          task,
          (
              TrainingTaskForSFT,
              TrainingTaskForRM,
              TrainingTaskForPPO,
              TrainingTaskForDPO,
              TrainingTaskForChatCompletion,
          ),
      ):
          raise ValueError(
              f"Training data {type(task)} is not supported yet"
          )
  
      return task.prepare_for_training(
          framework=framework,
          dataset=self,
          train_size=train_size,
          seed=seed,
          lang=lang,
      )
  
imports: import logging
  import textwrap
  import warnings
  from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Tuple, Union
  from argilla.client.feedback.constants import FETCHING_BATCH_SIZE
  from argilla.client.feedback.dataset import helpers
  from argilla.client.feedback.dataset.base import FeedbackDatasetBase, R
  from argilla.client.feedback.dataset.local.mixins import ArgillaMixin, TaskTemplateMixin
  from argilla.client.feedback.dataset.mixins import MetricsMixin, UnificationMixin
  from argilla.client.feedback.integrations.huggingface.dataset import HuggingFaceDatasetMixin
  from argilla.client.feedback.schemas.enums import RecordSortField, SortOrder
  from argilla.client.feedback.schemas.records import FeedbackRecord
  from argilla.client.feedback.schemas.vector_settings import VectorSettings
  from argilla.client.feedback.training.schemas.base import TrainingTaskForChatCompletion, TrainingTaskForDPO, TrainingTaskForPPO, TrainingTaskForQuestionAnswering, TrainingTaskForRM, TrainingTaskForSentenceSimilarity, TrainingTaskForSFT, TrainingTaskForTextClassification, TrainingTaskTypes
  from argilla.client.models import Framework
label_desc: Use image node_id 20 for calling the FeedbackDataset obj's underlying member method code with example usage: obj.prepare_for_training(framework, task, train_size, test_size, seed, lang) and returns: task