

'''simple docstring'''






import inspect
import unittest

from transformers import RegNetConfig
from transformers.file_utils import cached_property, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch
 from torch import nn

 from transformers import RegNetForImageClassification, RegNetModel
 from transformers.models.regnet.modeling_regnet import REGNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import AutoImageProcessor






class 			lowercase_	:




  """simple docstring"""




  def __init__(      self   :     Any					,lowercase__   :     Dict					,lowercase__   :     Any=3					,lowercase__   :     Dict=3_2					,lowercase__   :     str=3					,lowercase__   :     Any=1_0					,lowercase__   :     Optional[Any]=[1_0, 2_0, 3_0, 4_0]					,lowercase__   :     str=[1, 1, 2, 1]					,lowercase__   :     Tuple=True					,lowercase__   :     Optional[Any]=True					,lowercase__   :     Dict="relu"					,lowercase__   :     Optional[int]=3					,lowercase__   :     List[str]=None					,):
   __lowercase							  = parent
   __lowercase							  = batch_size
   __lowercase							  = image_size
   __lowercase							  = num_channels
   __lowercase							  = embeddings_size
   __lowercase							  = hidden_sizes
   __lowercase							  = depths
   __lowercase							  = is_training
   __lowercase							  = use_labels
   __lowercase							  = hidden_act
   __lowercase							  = num_labels
   __lowercase							  = scope
   __lowercase							  = len(lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Union[str, Any]			):
   __lowercase							  = floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

   __lowercase							  = None
   if self.use_labels:
    __lowercase							  = ids_tensor([self.batch_size]					,self.num_labels			)

   __lowercase							  = self.get_config()

   return config, pixel_values, labels






  def 					SCREAMING_SNAKE_CASE      (      self   :     int			):
   return RegNetConfig(
       num_channels=self.num_channels					,embeddings_size=self.embeddings_size					,hidden_sizes=self.hidden_sizes					,depths=self.depths					,hidden_act=self.hidden_act					,num_labels=self.num_labels					,)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Any					,lowercase__   :     List[Any]					,lowercase__   :     List[str]					,lowercase__   :     Any			):
   __lowercase							  = RegNetModel(config=lowercase__			)
   model.to(lowercase__			)
   model.eval()
   __lowercase							  = model(lowercase__			)
   # expected last hidden states: B, C, H // 32, W // 32
   self.parent.assertEqual(
       result.last_hidden_state.shape					,(self.batch_size, self.hidden_sizes[-1], self.image_size // 3_2, self.image_size // 3_2)					,)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Dict					,lowercase__   :     Any					,lowercase__   :     Any					,lowercase__   :     str			):
   __lowercase							  = self.num_labels
   __lowercase							  = RegNetForImageClassification(lowercase__			)
   model.to(lowercase__			)
   model.eval()
   __lowercase							  = model(lowercase__					,labels=lowercase__			)
   self.parent.assertEqual(result.logits.shape					,(self.batch_size, self.num_labels)			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[Any]			):
   __lowercase							  = self.prepare_config_and_inputs()
   __lowercase  ,	__lowercase  ,	__lowercase							  = config_and_inputs
   __lowercase							  = {'''pixel_values''': pixel_values}
   return config, inputs_dict






@require_torch
class 			lowercase_	(lowerCamelCase__				,       lowerCamelCase__				,       unittest.TestCase      ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE    :  Optional[int]							=			(RegNetModel, RegNetForImageClassification) if is_torch_available() else ()
  SCREAMING_SNAKE_CASE    :  Optional[Any]							=			(
      {'feature-extraction': RegNetModel, 'image-classification': RegNetForImageClassification}
      if is_torch_available()
      else {}
  )

  SCREAMING_SNAKE_CASE    :  Optional[int]							=			False
  SCREAMING_SNAKE_CASE    :  Any							=			False
  SCREAMING_SNAKE_CASE    :  int							=			False
  SCREAMING_SNAKE_CASE    :  Tuple							=			False






  def 					SCREAMING_SNAKE_CASE      (      self   :     Dict			):
   __lowercase							  = RegNetModelTester(self			)
   __lowercase							  = ConfigTester(self					,config_class=lowercase__					,has_text_modality=lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[Any]			):
   self.create_and_test_config_common_properties()
   self.config_tester.create_and_test_config_to_json_string()
   self.config_tester.create_and_test_config_to_json_file()
   self.config_tester.create_and_test_config_from_and_save_pretrained()
   self.config_tester.create_and_test_config_with_num_labels()
   self.config_tester.check_config_can_be_init_without_params()
   self.config_tester.check_config_arguments_init()






  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[Any]			):
   return






  @unittest.skip(reason='''RegNet does not use inputs_embeds'''			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Any			):
   pass






  @unittest.skip(reason='''RegNet does not support input and output embeddings'''			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     int			):
   pass






  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[Any]			):
   __lowercase  ,	__lowercase							  = self.model_tester.prepare_config_and_inputs_for_common()

   for model_class in self.all_model_classes:
    __lowercase							  = model_class(lowercase__			)
    __lowercase							  = inspect.signature(model.forward			)
    # signature.parameters is an OrderedDict => so arg_names order is deterministic
    __lowercase							  = [*signature.parameters.keys()]

    __lowercase							  = ['''pixel_values''']
    self.assertListEqual(arg_names[:1]					,lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Tuple			):
   __lowercase							  = self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_model(*lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Any			):
   __lowercase  ,	__lowercase							  = self.model_tester.prepare_config_and_inputs_for_common()

   for model_class in self.all_model_classes:
    __lowercase							  = model_class(config=lowercase__			)
    for name, module in model.named_modules():
     if isinstance(lowercase__					,(nn.BatchNormad, nn.GroupNorm)			):
      self.assertTrue(
          torch.all(module.weight == 1			)					,msg=F"Parameter {name} of model {model_class} seems not properly initialized"					,)
      self.assertTrue(
          torch.all(module.bias == 0			)					,msg=F"Parameter {name} of model {model_class} seems not properly initialized"					,)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Union[str, Any]			):
   def check_hidden_states_output(lowercase__   :     Any					,lowercase__   :     Union[str, Any]					,lowercase__   :     int			):
    __lowercase							  = model_class(lowercase__			)
    model.to(lowercase__			)
    model.eval()

    with torch.no_grad():
     __lowercase							  = model(**self._prepare_for_class(lowercase__					,lowercase__			)			)

    __lowercase							  = outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

    __lowercase							  = self.model_tester.num_stages
    self.assertEqual(len(lowercase__			)					,expected_num_stages + 1			)

    # RegNet's feature maps are of shape (batch_size, num_channels, height, width)
    self.assertListEqual(
        list(hidden_states[0].shape[-2:]			)					,[self.model_tester.image_size // 2, self.model_tester.image_size // 2]					,)

   __lowercase  ,	__lowercase							  = self.model_tester.prepare_config_and_inputs_for_common()
   __lowercase							  = ['''basic''', '''bottleneck''']
   for model_class in self.all_model_classes:
    for layer_type in layers_type:
     __lowercase							  = layer_type
     __lowercase							  = True
     check_hidden_states_output(lowercase__					,lowercase__					,lowercase__			)

     # check that output_hidden_states also work using config
     del inputs_dict["output_hidden_states"]
     __lowercase							  = True

     check_hidden_states_output(lowercase__					,lowercase__					,lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Tuple			):
   __lowercase							  = self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_image_classification(*lowercase__			)






  @slow
  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[int]			):
   for model_name in REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
    __lowercase							  = RegNetModel.from_pretrained(lowercase__			)
    self.assertIsNotNone(lowercase__			)


def 		_A     (    ):






 """simple docstring"""



 __lowercase							  = Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''      )
 return image






@require_torch
@require_vision
class 			lowercase_	(unittest.TestCase      ):




  """simple docstring"""




  @cached_property
  def 					SCREAMING_SNAKE_CASE      (      self   :     List[str]			):
   return (
       AutoImageProcessor.from_pretrained(REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]			)
       if is_vision_available()
       else None
   )






  @slow
  def 					SCREAMING_SNAKE_CASE      (      self   :     List[Any]			):
   __lowercase							  = RegNetForImageClassification.from_pretrained(REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]			).to(lowercase__			)

   __lowercase							  = self.default_image_processor
   __lowercase							  = prepare_img()
   __lowercase							  = image_processor(images=lowercase__					,return_tensors='''pt'''			).to(lowercase__			)

   # forward pass
   with torch.no_grad():
    __lowercase							  = model(**lowercase__			)

   # verify the logits
   __lowercase							  = torch.Size((1, 1_0_0_0)			)
   self.assertEqual(outputs.logits.shape					,lowercase__			)

   __lowercase							  = torch.tensor([-0.4_1_8_0, -1.5_0_5_1, -3.4_8_3_6]			).to(lowercase__			)

   self.assertTrue(torch.allclose(outputs.logits[0, :3]					,lowercase__					,atol=1e-4			)			)




'''simple docstring'''






import argparse
import json
import logging
import os
import shutil
import sys
import tempfile
import unittest
from unittest import mock

import torch
from accelerate.utils import write_basic_config

from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device
from transformers.utils import is_apex_available


logging.basicConfig(level=logging.DEBUG)

lowerCAmelCase__											=	logging.getLogger()


def 		_A     (    ):






 """simple docstring"""



 __lowercase							  = argparse.ArgumentParser()
 parser.add_argument('''-f'''      )
 __lowercase							  = parser.parse_args()
 return args.f


def 		_A     (    A__      ):






 """simple docstring"""



 __lowercase							  = {}
 __lowercase							  = os.path.join(A__     ,				'''all_results.json'''      )
 if os.path.exists(A__      ):
  with open(A__     ,				'''r'''      ) as f:
   __lowercase							  = json.load(A__      )
 else:
  raise ValueError(F"can't find {path}"      )
 return results


def 		_A     (    ):






 """simple docstring"""



 __lowercase							  = torch.cuda.is_available() and torch_device == '''cuda'''
 return is_using_cuda and is_apex_available()


lowerCAmelCase__											=	logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)






class 			lowercase_	(lowerCamelCase__      ):




  """simple docstring"""




  @classmethod
  def 					SCREAMING_SNAKE_CASE      (      cls   :     List[str]			):
   # Write Accelerate config, will pick up on CPU, GPU, and multi-GPU
   __lowercase							  = tempfile.mkdtemp()
   __lowercase							  = os.path.join(cls.tmpdir					,'''default_config.yml'''			)
   write_basic_config(save_location=cls.configPath			)
   __lowercase							  = ['''accelerate''', '''launch''', '''--config_file''', cls.configPath]






  @classmethod
  def 					SCREAMING_SNAKE_CASE      (      cls   :     str			):
   shutil.rmtree(cls.tmpdir			)






  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Any			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/text-classification/run_glue_no_trainer.py\n            --model_name_or_path distilbert-base-uncased\n            --output_dir {tmp_dir}\n            --train_file ./tests/fixtures/tests_samples/MRPC/train.csv\n            --validation_file ./tests/fixtures/tests_samples/MRPC/dev.csv\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --learning_rate=1e-4\n            --seed=42\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   if is_cuda_and_apex_available():
    testargs.append('''--fp16'''			)

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertGreaterEqual(result['''eval_accuracy''']					,0.7_5			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''glue_no_trainer'''			)			)			)






  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[int]			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/language-modeling/run_clm_no_trainer.py\n            --model_name_or_path distilgpt2\n            --train_file ./tests/fixtures/sample_text.txt\n            --validation_file ./tests/fixtures/sample_text.txt\n            --block_size 128\n            --per_device_train_batch_size 5\n            --per_device_eval_batch_size 5\n            --num_train_epochs 2\n            --output_dir {tmp_dir}\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   if torch.cuda.device_count() > 1:
    # Skipping because there are not enough batches to train the model + would need a drop_last to work.
    return

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertLess(result['''perplexity''']					,1_0_0			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''clm_no_trainer'''			)			)			)






  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[int]			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/language-modeling/run_mlm_no_trainer.py\n            --model_name_or_path distilroberta-base\n            --train_file ./tests/fixtures/sample_text.txt\n            --validation_file ./tests/fixtures/sample_text.txt\n            --output_dir {tmp_dir}\n            --num_train_epochs=1\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertLess(result['''perplexity''']					,4_2			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''mlm_no_trainer'''			)			)			)






  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Tuple			):
   # with so little data distributed training needs more epochs to get the score on par with 0/1 gpu
   __lowercase							  = 7 if get_gpu_count() > 1 else 2

   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/token-classification/run_ner_no_trainer.py\n            --model_name_or_path bert-base-uncased\n            --train_file tests/fixtures/tests_samples/conll/sample.json\n            --validation_file tests/fixtures/tests_samples/conll/sample.json\n            --output_dir {tmp_dir}\n            --learning_rate=2e-4\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=2\n            --num_train_epochs={epochs}\n            --seed 7\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertGreaterEqual(result['''eval_accuracy''']					,0.7_5			)
   self.assertLess(result['''train_loss''']					,0.5			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''ner_no_trainer'''			)			)			)






  @unittest.skip(reason='''Fix me @muellerzr'''			)
  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[Any]			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/question-answering/run_qa_no_trainer.py\n            --model_name_or_path bert-base-uncased\n            --version_2_with_negative\n            --train_file tests/fixtures/tests_samples/SQUAD/sample.json\n            --validation_file tests/fixtures/tests_samples/SQUAD/sample.json\n            --output_dir {tmp_dir}\n            --seed=42\n            --max_train_steps=10\n            --num_warmup_steps=2\n            --learning_rate=2e-4\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   # Because we use --version_2_with_negative the testing script uses SQuAD v2 metrics.
   self.assertGreaterEqual(result['''eval_f1''']					,2_8			)
   self.assertGreaterEqual(result['''eval_exact''']					,2_8			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''qa_no_trainer'''			)			)			)






  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Dict			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/multiple-choice/run_swag_no_trainer.py\n            --model_name_or_path bert-base-uncased\n            --train_file tests/fixtures/tests_samples/swag/sample.json\n            --validation_file tests/fixtures/tests_samples/swag/sample.json\n            --output_dir {tmp_dir}\n            --max_train_steps=20\n            --num_warmup_steps=2\n            --learning_rate=2e-4\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --with_tracking\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertGreaterEqual(result['''eval_accuracy''']					,0.8			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''swag_no_trainer'''			)			)			)






  @slow
  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     List[str]			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/summarization/run_summarization_no_trainer.py\n            --model_name_or_path t5-small\n            --train_file tests/fixtures/tests_samples/xsum/sample.json\n            --validation_file tests/fixtures/tests_samples/xsum/sample.json\n            --output_dir {tmp_dir}\n            --max_train_steps=50\n            --num_warmup_steps=8\n            --learning_rate=2e-4\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertGreaterEqual(result['''eval_rouge1''']					,1_0			)
   self.assertGreaterEqual(result['''eval_rouge2''']					,2			)
   self.assertGreaterEqual(result['''eval_rougeL''']					,7			)
   self.assertGreaterEqual(result['''eval_rougeLsum''']					,7			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''summarization_no_trainer'''			)			)			)






  @slow
  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     List[Any]			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/translation/run_translation_no_trainer.py\n            --model_name_or_path sshleifer/student_marian_en_ro_6_1\n            --source_lang en\n            --target_lang ro\n            --train_file tests/fixtures/tests_samples/wmt16/sample.json\n            --validation_file tests/fixtures/tests_samples/wmt16/sample.json\n            --output_dir {tmp_dir}\n            --max_train_steps=50\n            --num_warmup_steps=8\n            --num_beams=6\n            --learning_rate=3e-3\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --source_lang en_XX\n            --target_lang ro_RO\n            --checkpointing_steps epoch\n            --with_tracking\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertGreaterEqual(result['''eval_bleu''']					,3_0			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''epoch_0'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''translation_no_trainer'''			)			)			)






  @slow
  def 					SCREAMING_SNAKE_CASE      (      self   :     str			):
   __lowercase							  = logging.StreamHandler(sys.stdout			)
   logger.addHandler(lowercase__			)

   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py\n            --dataset_name huggingface/semantic-segmentation-test-sample\n            --output_dir {tmp_dir}\n            --max_train_steps=10\n            --num_warmup_steps=2\n            --learning_rate=2e-4\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --checkpointing_steps epoch\n        ".split()

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   self.assertGreaterEqual(result['''eval_overall_accuracy''']					,0.1_0			)






  @mock.patch.dict(os.environ					,{'''WANDB_MODE''': '''offline'''}			)
  def 					SCREAMING_SNAKE_CASE      (      self   :     Tuple			):
   __lowercase							  = self.get_auto_remove_tmp_dir()
   __lowercase							  = F"\n            {self.examples_dir}/pytorch/image-classification/run_image_classification_no_trainer.py\n            --model_name_or_path google/vit-base-patch16-224-in21k\n            --dataset_name hf-internal-testing/cats_vs_dogs_sample\n            --learning_rate 1e-4\n            --per_device_train_batch_size 2\n            --per_device_eval_batch_size 1\n            --max_train_steps 2\n            --train_val_split 0.1\n            --seed 42\n            --output_dir {tmp_dir}\n            --with_tracking\n            --checkpointing_steps 1\n        ".split()

   if is_cuda_and_apex_available():
    testargs.append('''--fp16'''			)

   run_command(self._launch_args + testargs			)
   __lowercase							  = get_results(lowercase__			)
   # The base model scores a 25%
   self.assertGreaterEqual(result['''eval_accuracy''']					,0.6			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''step_1'''			)			)			)
   self.assertTrue(os.path.exists(os.path.join(lowercase__					,'''image_classification_no_trainer'''			)			)			)

