






"""simple docstring"""


import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)


class 					snake_case		(							unittest.TestCase						):


   '''simple docstring'''

   def 				_SCREAMING_SNAKE_CASE				(	self :     int  ):

     '''simple docstring'''
     __A									= ['''a''', '''b''', '''c''']

     # Defaults to last layer if both are None
     __A			,    __A									= get_aligned_output_features_output_indices(__UpperCAmelCase,       __UpperCAmelCase,       __UpperCAmelCase  )
     self.assertEqual(__UpperCAmelCase,       ['''c''']  )
     self.assertEqual(__UpperCAmelCase,       [2]  )

     # Out indices set to match out features
     __A			,    __A									= get_aligned_output_features_output_indices(['''a''', '''c'''],       __UpperCAmelCase,       __UpperCAmelCase  )
     self.assertEqual(__UpperCAmelCase,       ['''a''', '''c''']  )
     self.assertEqual(__UpperCAmelCase,       [0, 2]  )

     # Out features set to match out indices
     __A			,    __A									= get_aligned_output_features_output_indices(__UpperCAmelCase,       [0, 2],       __UpperCAmelCase  )
     self.assertEqual(__UpperCAmelCase,       ['''a''', '''c''']  )
     self.assertEqual(__UpperCAmelCase,       [0, 2]  )

     # Out features selected from negative indices
     __A			,    __A									= get_aligned_output_features_output_indices(__UpperCAmelCase,       [-3, -1],       __UpperCAmelCase  )
     self.assertEqual(__UpperCAmelCase,       ['''a''', '''c''']  )
     self.assertEqual(__UpperCAmelCase,       [-3, -1]  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     Dict  ):

     '''simple docstring'''
     # Stage names must be set
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(['''a''', '''b'''],       (0, 1),       __UpperCAmelCase  )

     # Out features must be a list
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(('''a''', '''b'''),       (0, 1),       ['''a''', '''b''']  )

     # Out features must be a subset of stage names
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(['''a''', '''b'''],       (0, 1),       ['''a''']  )

     # Out indices must be a list or tuple
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(__UpperCAmelCase,       0,       ['''a''', '''b''']  )

     # Out indices must be a subset of stage names
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(__UpperCAmelCase,       (0, 1),       ['''a''']  )

     # Out features and out indices must be the same length
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(['''a''', '''b'''],       (0,),       ['''a''', '''b''', '''c''']  )

     # Out features should match out indices
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(['''a''', '''b'''],       (0, 2),       ['''a''', '''b''', '''c''']  )

     # Out features and out indices should be in order
     with self.assertRaises(__UpperCAmelCase  ):
       verify_out_features_out_indices(['''b''', '''a'''],       (0, 1),       ['''a''', '''b''']  )

     # Check passes with valid inputs
     verify_out_features_out_indices(['''a''', '''b''', '''d'''],       (0, 1, -1),       ['''a''', '''b''', '''c''', '''d''']  )






   def 				_SCREAMING_SNAKE_CASE				(	self :     Tuple  ):

     '''simple docstring'''
     __A									= BackboneMixin()

     __A									= ['''a''', '''b''', '''c''']
     __A									= ['''a''', '''c''']
     __A									= [0, 2]

     # Check that the output features and indices are set correctly
     self.assertEqual(backbone.out_features,       ['''a''', '''c''']  )
     self.assertEqual(backbone.out_indices,       [0, 2]  )

     # Check out features and indices are updated correctly
     __A									= ['''a''', '''b''']
     self.assertEqual(backbone.out_features,       ['''a''', '''b''']  )
     self.assertEqual(backbone.out_indices,       [0, 1]  )

     __A									= [-3, -1]
     self.assertEqual(backbone.out_features,       ['''a''', '''c''']  )
     self.assertEqual(backbone.out_indices,       [-3, -1]  )





"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__lowerCamelCase							 =     {
    "configuration_chinese_clip": [
        "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "ChineseCLIPConfig",
        "ChineseCLIPOnnxConfig",
        "ChineseCLIPTextConfig",
        "ChineseCLIPVisionConfig",
    ],
    "processing_chinese_clip": ["ChineseCLIPProcessor"],
}

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase							 =     ["ChineseCLIPFeatureExtractor"]
				__lowerCamelCase							 =     ["ChineseCLIPImageProcessor"]

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase							 =     [
				    "CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "ChineseCLIPModel",
				    "ChineseCLIPPreTrainedModel",
				    "ChineseCLIPTextModel",
				    "ChineseCLIPVisionModel",
				]

if TYPE_CHECKING:
				from .configuration_chinese_clip import (
				    CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    ChineseCLIPConfig,
				    ChineseCLIPOnnxConfig,
				    ChineseCLIPTextConfig,
				    ChineseCLIPVisionConfig,
				)
				from .processing_chinese_clip import ChineseCLIPProcessor

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_chinese_clip import ChineseCLIPFeatureExtractor, ChineseCLIPImageProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_chinese_clip import (
								    CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
								    ChineseCLIPModel,
								    ChineseCLIPPreTrainedModel,
								    ChineseCLIPTextModel,
								    ChineseCLIPVisionModel,
								)

else:
				import sys

				__lowerCamelCase							 =     _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





