




import inspect
import unittest

from transformers import ViTConfig
from transformers.testing_utils import (
    require_accelerate,
    require_torch,
    require_torch_gpu,
    require_vision,
    slow,
    torch_device,
)
from transformers.utils import cached_property, is_torch_available, is_vision_available

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 ViTForImageClassification, ViTForMaskedImageModeling, ViTModel
   from transformers.models.vit.modeling_vit import VIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
   from PIL import Image

   from transformers import ViTImageProcessor





class 			lowerCamelCase_				:


 '''simple docstring'''







 def __init__(				self    :						Any							,							_lowerCAmelCase    :						str							,							_lowerCAmelCase    :						int=13							,							_lowerCAmelCase    :						Tuple=30							,							_lowerCAmelCase    :						Any=2							,							_lowerCAmelCase    :						Optional[Any]=3							,							_lowerCAmelCase    :						Optional[Any]=True							,							_lowerCAmelCase    :						Any=True							,							_lowerCAmelCase    :						List[Any]=32							,							_lowerCAmelCase    :						Optional[Any]=5							,							_lowerCAmelCase    :						List[Any]=4							,							_lowerCAmelCase    :						int=37							,							_lowerCAmelCase    :						Optional[Any]="gelu"							,							_lowerCAmelCase    :						Tuple=0.1							,							_lowerCAmelCase    :						Union[str, Any]=0.1							,							_lowerCAmelCase    :						Union[str, Any]=10							,							_lowerCAmelCase    :						Dict=0.02							,							_lowerCAmelCase    :						Optional[Any]=None							,							_lowerCAmelCase    :						Dict=2							,							):
       SCREAMING_SNAKE_CASE_      		=     parent
       SCREAMING_SNAKE_CASE_      		=     batch_size
       SCREAMING_SNAKE_CASE_      		=     image_size
       SCREAMING_SNAKE_CASE_      		=     patch_size
       SCREAMING_SNAKE_CASE_      		=     num_channels
       SCREAMING_SNAKE_CASE_      		=     is_training
       SCREAMING_SNAKE_CASE_      		=     use_labels
       SCREAMING_SNAKE_CASE_      		=     hidden_size
       SCREAMING_SNAKE_CASE_      		=     num_hidden_layers
       SCREAMING_SNAKE_CASE_      		=     num_attention_heads
       SCREAMING_SNAKE_CASE_      		=     intermediate_size
       SCREAMING_SNAKE_CASE_      		=     hidden_act
       SCREAMING_SNAKE_CASE_      		=     hidden_dropout_prob
       SCREAMING_SNAKE_CASE_      		=     attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE_      		=     type_sequence_label_size
       SCREAMING_SNAKE_CASE_      		=     initializer_range
       SCREAMING_SNAKE_CASE_      		=     scope
       SCREAMING_SNAKE_CASE_      		=     encoder_stride

       # in ViT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
       SCREAMING_SNAKE_CASE_      		=     (image_size // patch_size) ** 2
       SCREAMING_SNAKE_CASE_      		=     num_patches + 1



 def  lowerCAmelCase_    (				self    :						List[Any]		):
       SCREAMING_SNAKE_CASE_      		=     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]		)

       SCREAMING_SNAKE_CASE_      		=     None
       if self.use_labels:
             SCREAMING_SNAKE_CASE_      		=     ids_tensor([self.batch_size]							,							self.type_sequence_label_size		)

       SCREAMING_SNAKE_CASE_      		=     self.get_config()

       return config, pixel_values, labels



 def  lowerCAmelCase_    (				self    :						str		):
       return ViTConfig(
           image_size=self.image_size							,							patch_size=self.patch_size							,							num_channels=self.num_channels							,							hidden_size=self.hidden_size							,							num_hidden_layers=self.num_hidden_layers							,							num_attention_heads=self.num_attention_heads							,							intermediate_size=self.intermediate_size							,							hidden_act=self.hidden_act							,							hidden_dropout_prob=self.hidden_dropout_prob							,							attention_probs_dropout_prob=self.attention_probs_dropout_prob							,							is_decoder=_lowerCAmelCase							,							initializer_range=self.initializer_range							,							encoder_stride=self.encoder_stride							,							)



 def  lowerCAmelCase_    (				self    :						str							,							_lowerCAmelCase    :						Any							,							_lowerCAmelCase    :						int							,							_lowerCAmelCase    :						str		):
       SCREAMING_SNAKE_CASE_      		=     ViTModel(config=_lowerCAmelCase		)
       model.to(_lowerCAmelCase		)
       model.eval()
       SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase		)
       self.parent.assertEqual(result.last_hidden_state.shape							,							(self.batch_size, self.seq_length, self.hidden_size)		)



 def  lowerCAmelCase_    (				self    :						Any							,							_lowerCAmelCase    :						List[str]							,							_lowerCAmelCase    :						List[str]							,							_lowerCAmelCase    :						Optional[int]		):
       SCREAMING_SNAKE_CASE_      		=     ViTForMaskedImageModeling(config=_lowerCAmelCase		)
       model.to(_lowerCAmelCase		)
       model.eval()
       SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase		)
       self.parent.assertEqual(
           result.reconstruction.shape							,							(self.batch_size, self.num_channels, self.image_size, self.image_size)		)

       # test greyscale images
       SCREAMING_SNAKE_CASE_      		=     1
       SCREAMING_SNAKE_CASE_      		=     ViTForMaskedImageModeling(_lowerCAmelCase		)
       model.to(_lowerCAmelCase		)
       model.eval()

       SCREAMING_SNAKE_CASE_      		=     floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
       SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase		)
       self.parent.assertEqual(result.reconstruction.shape							,							(self.batch_size, 1, self.image_size, self.image_size)		)



 def  lowerCAmelCase_    (				self    :						Dict							,							_lowerCAmelCase    :						Tuple							,							_lowerCAmelCase    :						Dict							,							_lowerCAmelCase    :						Optional[Any]		):
       SCREAMING_SNAKE_CASE_      		=     self.type_sequence_label_size
       SCREAMING_SNAKE_CASE_      		=     ViTForImageClassification(_lowerCAmelCase		)
       model.to(_lowerCAmelCase		)
       model.eval()
       SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase							,							labels=_lowerCAmelCase		)
       self.parent.assertEqual(result.logits.shape							,							(self.batch_size, self.type_sequence_label_size)		)

       # test greyscale images
       SCREAMING_SNAKE_CASE_      		=     1
       SCREAMING_SNAKE_CASE_      		=     ViTForImageClassification(_lowerCAmelCase		)
       model.to(_lowerCAmelCase		)
       model.eval()

       SCREAMING_SNAKE_CASE_      		=     floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
       SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase		)
       self.parent.assertEqual(result.logits.shape							,							(self.batch_size, self.type_sequence_label_size)		)




 def  lowerCAmelCase_    (				self    :						str		):
       SCREAMING_SNAKE_CASE_      		=     self.prepare_config_and_inputs()
       (
           (
           SCREAMING_SNAKE_CASE_
       )		,					(
           SCREAMING_SNAKE_CASE_
       )		,					(
           SCREAMING_SNAKE_CASE_
       )		,					
       )      		=     config_and_inputs
       SCREAMING_SNAKE_CASE_      		=     {'pixel_values': pixel_values}
       return config, inputs_dict





@require_torch
class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE			,  _SCREAMING_SNAKE_CASE			,  unittest.TestCase   ):


 '''simple docstring'''







 lowercase_							       =       (
     (
         ViTModel,
         ViTForImageClassification,
         ViTForMaskedImageModeling,
     )
     if is_torch_available()
     else ()
 )
 lowercase_							       =       (
     {"feature-extraction": ViTModel, "image-classification": ViTForImageClassification}
     if is_torch_available()
     else {}
 )
 lowercase_							       =       True

 lowercase_							       =       False
 lowercase_							       =       False
 lowercase_							       =       False



 def  lowerCAmelCase_    (				self    :						Union[str, Any]		):
       SCREAMING_SNAKE_CASE_      		=     ViTModelTester(self		)
       SCREAMING_SNAKE_CASE_      		=     ConfigTester(self							,							config_class=_lowerCAmelCase							,							has_text_modality=_lowerCAmelCase							,							hidden_size=37		)



 def  lowerCAmelCase_    (				self    :						int		):
       self.config_tester.run_common_tests()



 @unittest.skip(reason='ViT does not use inputs_embeds'		)
 def  lowerCAmelCase_    (				self    :						List[str]		):
       pass



 def  lowerCAmelCase_    (				self    :						Union[str, Any]		):
       SCREAMING_SNAKE_CASE_		,					SCREAMING_SNAKE_CASE_      		=     self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
             SCREAMING_SNAKE_CASE_      		=     model_class(_lowerCAmelCase		)
             self.assertIsInstance(model.get_input_embeddings()							,							(nn.Module)		)
             SCREAMING_SNAKE_CASE_      		=     model.get_output_embeddings()
             self.assertTrue(x is None or isinstance(_lowerCAmelCase							,							nn.Linear		)		)



 def  lowerCAmelCase_    (				self    :						str		):
       SCREAMING_SNAKE_CASE_		,					SCREAMING_SNAKE_CASE_      		=     self.model_tester.prepare_config_and_inputs_for_common()

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

             SCREAMING_SNAKE_CASE_      		=     ['pixel_values']
             self.assertListEqual(arg_names[:1]							,							_lowerCAmelCase		)



 def  lowerCAmelCase_    (				self    :						Dict		):
       SCREAMING_SNAKE_CASE_      		=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*_lowerCAmelCase		)



 def  lowerCAmelCase_    (				self    :						Union[str, Any]		):
       SCREAMING_SNAKE_CASE_      		=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_image_modeling(*_lowerCAmelCase		)



 def  lowerCAmelCase_    (				self    :						Optional[int]		):
       SCREAMING_SNAKE_CASE_      		=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*_lowerCAmelCase		)




 @slow
 def  lowerCAmelCase_    (				self    :						List[Any]		):
       for model_name in VIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             SCREAMING_SNAKE_CASE_      		=     ViTModel.from_pretrained(_lowerCAmelCase		)
             self.assertIsNotNone(_lowerCAmelCase		)


def    UpperCAmelCase_				( )   ->					Optional[Any]:
      SCREAMING_SNAKE_CASE_      		=     Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'				)
      return image





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


 '''simple docstring'''







 @cached_property
 def  lowerCAmelCase_    (				self    :						Tuple		):
       return ViTImageProcessor.from_pretrained('google/vit-base-patch16-224'		) if is_vision_available() else None



 @slow
 def  lowerCAmelCase_    (				self    :						List[Any]		):
       SCREAMING_SNAKE_CASE_      		=     ViTForImageClassification.from_pretrained('google/vit-base-patch16-224'		).to(_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_      		=     self.default_image_processor
       SCREAMING_SNAKE_CASE_      		=     prepare_img()
       SCREAMING_SNAKE_CASE_      		=     image_processor(images=_lowerCAmelCase							,							return_tensors='pt'		).to(_lowerCAmelCase		)

       # forward pass
       with torch.no_grad():
             SCREAMING_SNAKE_CASE_      		=     model(**_lowerCAmelCase		)

       # verify the logits
       SCREAMING_SNAKE_CASE_      		=     torch.Size((1, 1_000)		)
       self.assertEqual(outputs.logits.shape							,							_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_      		=     torch.tensor([-0.2744, 0.8215, -0.0836]		).to(_lowerCAmelCase		)

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



 @slow
 def  lowerCAmelCase_    (				self    :						int		):
       # ViT models have an `interpolate_pos_encoding` argument in their forward method,
       # allowing to interpolate the pre-trained position embeddings in order to use
       # the model on higher resolutions. The DINO model by Facebook AI leverages this
       # to visualize self-attention on higher resolution images.
       SCREAMING_SNAKE_CASE_      		=     ViTModel.from_pretrained('facebook/dino-vits8'		).to(_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_      		=     ViTImageProcessor.from_pretrained('facebook/dino-vits8'							,							size=480		)
       SCREAMING_SNAKE_CASE_      		=     prepare_img()
       SCREAMING_SNAKE_CASE_      		=     image_processor(images=_lowerCAmelCase							,							return_tensors='pt'		)
       SCREAMING_SNAKE_CASE_      		=     inputs.pixel_values.to(_lowerCAmelCase		)

       # forward pass
       with torch.no_grad():
             SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase							,							interpolate_pos_encoding=_lowerCAmelCase		)

       # verify the logits
       SCREAMING_SNAKE_CASE_      		=     torch.Size((1, 3_601, 384)		)
       self.assertEqual(outputs.last_hidden_state.shape							,							_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_      		=     torch.tensor(
           [[4.2340, 4.3906, -6.6692], [4.5463, 1.8928, -6.7257], [4.4429, 0.8496, -5.8585]]		).to(_lowerCAmelCase		)

       self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]							,							_lowerCAmelCase							,							atol=1E-4		)		)




 @slow
 @require_accelerate
 @require_torch_gpu
 def  lowerCAmelCase_    (				self    :						Optional[int]		):
       SCREAMING_SNAKE_CASE_      		=     ViTModel.from_pretrained('facebook/dino-vits8'							,							torch_dtype=torch.floataa							,							device_map='auto'		)
       SCREAMING_SNAKE_CASE_      		=     self.default_image_processor

       SCREAMING_SNAKE_CASE_      		=     prepare_img()
       SCREAMING_SNAKE_CASE_      		=     image_processor(images=_lowerCAmelCase							,							return_tensors='pt'		)
       SCREAMING_SNAKE_CASE_      		=     inputs.pixel_values.to(_lowerCAmelCase		)

       # forward pass to make sure inference works in fp16
       with torch.no_grad():
             SCREAMING_SNAKE_CASE_      		=     model(_lowerCAmelCase		)





import subprocess
import sys

from transformers import BertConfig, BertModel, BertTokenizer, pipeline
from transformers.testing_utils import TestCasePlus, require_torch





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 @require_torch
 def  lowerCAmelCase_    (				self    :						int		):
       # this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
       # `transformers` is loaded, and it's too late for inside pytest - so we are changing it
       # while running an external program

       # python one-liner segments

       # this must be loaded before socket.socket is monkey-patched
       SCREAMING_SNAKE_CASE_      		=     '\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nmname = "hf-internal-testing/tiny-random-bert"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nBertTokenizer.from_pretrained(mname)\npipe = pipeline(task="fill-mask", model=mname)\nprint("success")\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nimport socket\ndef offline_socket(*args, **kwargs): raise RuntimeError("Offline mode is enabled, we shouldn\'t access internet")\nsocket.socket = offline_socket\n        '

       # Force fetching the files so that we can use the cache
       SCREAMING_SNAKE_CASE_      		=     'hf-internal-testing/tiny-random-bert'
       BertConfig.from_pretrained(_lowerCAmelCase		)
       BertModel.from_pretrained(_lowerCAmelCase		)
       BertTokenizer.from_pretrained(_lowerCAmelCase		)
       pipeline(task='fill-mask'							,							model=_lowerCAmelCase		)

       # baseline - just load from_pretrained with normal network
       SCREAMING_SNAKE_CASE_      		=     [sys.executable, '-c', '\n'.join([load, run, mock]		)]

       # should succeed
       SCREAMING_SNAKE_CASE_      		=     self.get_env()
       # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
       SCREAMING_SNAKE_CASE_      		=     '1'
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							0							,							result.stderr		)
       self.assertIn('success'							,							result.stdout.decode()		)



 @require_torch
 def  lowerCAmelCase_    (				self    :						Tuple		):
       # python one-liner segments
       # this must be loaded before socket.socket is monkey-patched
       SCREAMING_SNAKE_CASE_      		=     '\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nmname = "hf-internal-testing/tiny-random-bert"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nBertTokenizer.from_pretrained(mname)\npipe = pipeline(task="fill-mask", model=mname)\nprint("success")\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error("Faking flaky internet")\nsocket.socket = offline_socket\n        '

       # Force fetching the files so that we can use the cache
       SCREAMING_SNAKE_CASE_      		=     'hf-internal-testing/tiny-random-bert'
       BertConfig.from_pretrained(_lowerCAmelCase		)
       BertModel.from_pretrained(_lowerCAmelCase		)
       BertTokenizer.from_pretrained(_lowerCAmelCase		)
       pipeline(task='fill-mask'							,							model=_lowerCAmelCase		)

       # baseline - just load from_pretrained with normal network
       SCREAMING_SNAKE_CASE_      		=     [sys.executable, '-c', '\n'.join([load, run, mock]		)]

       # should succeed
       SCREAMING_SNAKE_CASE_      		=     self.get_env()
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							0							,							result.stderr		)
       self.assertIn('success'							,							result.stdout.decode()		)



 @require_torch
 def  lowerCAmelCase_    (				self    :						List[str]		):
       # this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
       # `transformers` is loaded, and it's too late for inside pytest - so we are changing it
       # while running an external program

       # python one-liner segments

       # this must be loaded before socket.socket is monkey-patched
       SCREAMING_SNAKE_CASE_      		=     '\nfrom transformers import BertConfig, BertModel, BertTokenizer\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nmname = "hf-internal-testing/tiny-random-bert-sharded"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nprint("success")\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nimport socket\ndef offline_socket(*args, **kwargs): raise ValueError("Offline mode is enabled")\nsocket.socket = offline_socket\n        '

       # baseline - just load from_pretrained with normal network
       SCREAMING_SNAKE_CASE_      		=     [sys.executable, '-c', '\n'.join([load, run]		)]

       # should succeed
       SCREAMING_SNAKE_CASE_      		=     self.get_env()
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							0							,							result.stderr		)
       self.assertIn('success'							,							result.stdout.decode()		)

       # next emulate no network
       SCREAMING_SNAKE_CASE_      		=     [sys.executable, '-c', '\n'.join([load, mock, run]		)]

       # Doesn't fail anymore since the model is in the cache due to other tests, so commenting this.
       # env["TRANSFORMERS_OFFLINE"] = "0"
       # result = subprocess.run(cmd, env=env, check=False, capture_output=True)
       # self.assertEqual(result.returncode, 1, result.stderr)

       # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
       SCREAMING_SNAKE_CASE_      		=     '1'
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							0							,							result.stderr		)
       self.assertIn('success'							,							result.stdout.decode()		)



 @require_torch
 def  lowerCAmelCase_    (				self    :						Any		):
       SCREAMING_SNAKE_CASE_      		=     '\nfrom transformers import pipeline\n        '
       SCREAMING_SNAKE_CASE_      		=     '\nmname = "hf-internal-testing/tiny-random-bert"\npipe = pipeline(model=mname)\n        '

       SCREAMING_SNAKE_CASE_      		=     '\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error("Offline mode is enabled")\nsocket.socket = offline_socket\n        '
       SCREAMING_SNAKE_CASE_      		=     self.get_env()
       SCREAMING_SNAKE_CASE_      		=     '1'
       SCREAMING_SNAKE_CASE_      		=     [sys.executable, '-c', '\n'.join([load, mock, run]		)]
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							1							,							result.stderr		)
       self.assertIn(
           'You cannot infer task automatically within `pipeline` when using offline mode'							,							result.stderr.decode().replace('\n'							,							''		)							,							)




 @require_torch
 def  lowerCAmelCase_    (				self    :						Optional[int]		):
       SCREAMING_SNAKE_CASE_      		=     '\nfrom transformers import AutoModel\n        '
       SCREAMING_SNAKE_CASE_      		=     '\nmname = "hf-internal-testing/test_dynamic_model"\nAutoModel.from_pretrained(mname, trust_remote_code=True)\nprint("success")\n        '

       # baseline - just load from_pretrained with normal network
       SCREAMING_SNAKE_CASE_      		=     [sys.executable, '-c', '\n'.join([load, run]		)]

       # should succeed
       SCREAMING_SNAKE_CASE_      		=     self.get_env()
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							0							,							result.stderr		)
       self.assertIn('success'							,							result.stdout.decode()		)

       # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
       SCREAMING_SNAKE_CASE_      		=     '1'
       SCREAMING_SNAKE_CASE_      		=     subprocess.run(_lowerCAmelCase							,							env=_lowerCAmelCase							,							check=_lowerCAmelCase							,							capture_output=_lowerCAmelCase		)
       self.assertEqual(result.returncode							,							0							,							result.stderr		)
       self.assertIn('success'							,							result.stdout.decode()		)