docstr: We create an openai.FineTune object from a pre-trained model, and send data to finetune it.
docstr_tok: ["We","create","an","openai.FineTune","object","from","a","pre-trained","model",",","and","send","data","to","finetune","it","."]
code: def train(self, output_dir: str = None) -> None:
      """
      We create an openai.FineTune object from a pre-trained model, and send data to finetune it.
      """
  
      import openai
  
      if output_dir is not None:
          self.trainer_kwargs["suffix"] = output_dir
  
      if (
          self._train_dataset is not None
          and self.trainer_kwargs["training_file"] is None
      ):
          self.trainer_kwargs[
              "training_file"
          ] = self.upload_dataset_to_openai(
              self._train_dataset, "data_train.jsonl"
          )
      if (
          self._eval_dataset is not None
          and self.trainer_kwargs["validation_file"] is None
      ) and self.trainer_kwargs["compute_classification_metrics"]:
          self.trainer_kwargs[
              "validation_file"
          ] = self.upload_dataset_to_openai(
              self._eval_dataset, "data_test.jsonl"
          )
  
      self.update_config()
  
      started_training = False
      while not started_training:
          try:
              if self.__legacy:
                  response = openai.FineTune.create(
                      **self.trainer_kwargs,
                  )
              else:
                  response = openai.FineTuningJob.create(
                      **self.trainer_kwargs
                  )
              started_training = True
          except Exception as e:
              self._logger.warning(e)
              self._logger.warning(
                  f"Retrying in {self.sleep_timer} seconds."
              )
  
              time.sleep(self.sleep_timer)
  
      self._logger.info(response)
      self.finetune_id = response.id
  
      if self.__legacy:
          message = f"`openai.FineTune.retrieve('{self.finetune_id}')`"
      else:
          message = (
              f"`openai.FineTuningJob.retrieve('{self.finetune_id}')`"
          )
      self._logger.info(
          f"Waiting for training OpenAI will send an email when done. Get info by running: {message}."
      )
  
imports: import logging
  import os
  import time
  from typing import List, Optional, Union
  import numpy
  from argilla._constants import OPENAI_END_TOKEN, OPENAI_LEGACY_MODELS, OPENAI_SEPARATOR, OPENAI_WHITESPACE
  from argilla.client.models import TextClassificationRecord, TokenClassificationRecord
  from argilla.datasets import TextClassificationSettings, TokenClassificationSettings
  from argilla.training.base import ArgillaTrainerSkeleton
  from argilla.training.utils import filter_allowed_args
  from argilla.utils.dependency import require_dependencies
label_desc: Use image node_id 7 for calling the ArgillaOpenAITrainer obj's underlying member method code with example usage: obj.train(output_dir) without return types