code: 
  
  
  import unittest
  
  from transformers import (
      MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
      TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
      PreTrainedTokenizer,
      is_vision_available,
  )
  from transformers.pipelines import ImageClassificationPipeline, pipeline
  from transformers.testing_utils import (
      is_pipeline_test,
      nested_simplify,
      require_tf,
      require_torch,
      require_torch_or_tf,
      require_vision,
      slow,
  )
  
  from .test_pipelines_common import ANY
  
  
  if is_vision_available():
   from PIL import Image
  else:
  
   class 						A__      :
  
  
  
  
  
  
  
       """simple docstring"""
  
       @staticmethod
       def 	a_    ( *__snake_case    ,      **__snake_case					):
            pass
  
  @is_pipeline_test
  @require_torch_or_tf
  @require_vision
  class 						A__      (					unittest.TestCase			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      __magic_name__    						=	MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
      __magic_name__    						=	TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
      def 	a_    ( self    ,      __snake_case    ,      __snake_case    ,      __snake_case					):
           snake_case					=       ImageClassificationPipeline(model=__snake_case    ,      image_processor=__snake_case    ,      top_k=2					)
           snake_case					=       [
               Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''					),
               '''http://images.cocodataset.org/val2017/000000039769.jpg''',
           ]
           return image_classifier, examples
      def 	a_    ( self    ,      __snake_case    ,      __snake_case					):
           snake_case					=       image_classifier('''./tests/fixtures/tests_samples/COCO/000000039769.png'''					)
  
           self.assertEqual(
               __snake_case    ,      [
                   {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                   {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
               ]    ,      )
  
           import datasets
  
           snake_case					=       datasets.load_dataset('''hf-internal-testing/fixtures_image_utils'''    ,      '''image'''    ,      split='''test'''					)
  
           # Accepts URL + PIL.Image + lists
           snake_case					=       image_classifier(
               [
                   Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''					),
                   '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                   # RGBA
                   dataset[0]['''file'''],
                   # LA
                   dataset[1]['''file'''],
                   # L
                   dataset[2]['''file'''],
               ]					)
           self.assertEqual(
               __snake_case    ,      [
                   [
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                   ],
                   [
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                   ],
                   [
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                   ],
                   [
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                   ],
                   [
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                       {'''score''': ANY(__snake_case					), '''label''': ANY(__snake_case					)},
                   ],
               ]    ,      )
      @require_torch
      def 	a_    ( self					):
           snake_case					=       '''hf-internal-testing/tiny-random-vit'''
           snake_case					=       pipeline('''image-classification'''    ,      model=__snake_case					)
  
           snake_case					=       image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}]    ,      )
  
           snake_case					=       image_classifier(
               [
                   '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                   '''http://images.cocodataset.org/val2017/000000039769.jpg''',
               ]    ,      top_k=2    ,      )
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [
                   [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
                   [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
               ]    ,      )
      @require_tf
      def 	a_    ( self					):
           snake_case					=       '''hf-internal-testing/tiny-random-vit'''
           snake_case					=       pipeline('''image-classification'''    ,      model=__snake_case    ,      framework='''tf'''					)
  
           snake_case					=       image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}]    ,      )
  
           snake_case					=       image_classifier(
               [
                   '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                   '''http://images.cocodataset.org/val2017/000000039769.jpg''',
               ]    ,      top_k=2    ,      )
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [
                   [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
                   [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
               ]    ,      )
      def 	a_    ( self					):
           snake_case					=       PreTrainedTokenizer()
  
           # Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
           snake_case					=       pipeline(
               '''image-classification'''    ,      model='''hf-internal-testing/tiny-random-vit'''    ,      tokenizer=__snake_case					)
  
           self.assertIs(image_classifier.tokenizer    ,      __snake_case					)
  
  
  
  
      @slow
      @require_torch
      def 	a_    ( self					):
           # Perceiver is not tested by `run_pipeline_test` properly.
           # That is because the type of feature_extractor and model preprocessor need to be kept
           # in sync, which is not the case in the current design
           snake_case					=       pipeline('''image-classification'''    ,      model='''deepmind/vision-perceiver-conv'''					)
           snake_case					=       image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [
                   {'''score''': 0.4385, '''label''': '''tabby, tabby cat'''},
                   {'''score''': 0.321, '''label''': '''tiger cat'''},
                   {'''score''': 0.0502, '''label''': '''Egyptian cat'''},
                   {'''score''': 0.0137, '''label''': '''crib, cot'''},
                   {'''score''': 0.007, '''label''': '''radiator'''},
               ]    ,      )
  
           snake_case					=       pipeline('''image-classification'''    ,      model='''deepmind/vision-perceiver-fourier'''					)
           snake_case					=       image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [
                   {'''score''': 0.5658, '''label''': '''tabby, tabby cat'''},
                   {'''score''': 0.1309, '''label''': '''tiger cat'''},
                   {'''score''': 0.0722, '''label''': '''Egyptian cat'''},
                   {'''score''': 0.0707, '''label''': '''remote control, remote'''},
                   {'''score''': 0.0082, '''label''': '''computer keyboard, keypad'''},
               ]    ,      )
  
           snake_case					=       pipeline('''image-classification'''    ,      model='''deepmind/vision-perceiver-learned'''					)
           snake_case					=       image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
           self.assertEqual(
               nested_simplify(__snake_case    ,      decimals=4					)    ,      [
                   {'''score''': 0.3022, '''label''': '''tabby, tabby cat'''},
                   {'''score''': 0.2362, '''label''': '''Egyptian cat'''},
                   {'''score''': 0.1856, '''label''': '''tiger cat'''},
                   {'''score''': 0.0324, '''label''': '''remote control, remote'''},
                   {'''score''': 0.0096, '''label''': '''quilt, comforter, comfort, puff'''},
               ]    ,      )
  
  
  
  
  
style_context: 
  
  
  from ..utils import deprecate
  from .attention_processor import (  # noqa: F401
      Attention,
      AttentionProcessor,
      AttnAddedKVProcessor,
      AttnProcessor2_0,
      LoRAAttnProcessor,
      LoRALinearLayer,
      LoRAXFormersAttnProcessor,
      SlicedAttnAddedKVProcessor,
      SlicedAttnProcessor,
      XFormersAttnProcessor,
  )
  from .attention_processor import AttnProcessor as AttnProcessorRename  # noqa: F401
  
  
  deprecate(
      "cross_attention",
      "0.20.0",
      "Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.",
      standard_warn=False,
  )
  
  
  _SCREAMING_SNAKE_CASE    :				Optional[int]       =					AttentionProcessor
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  
  
  class 						A__      (					snake_case__			):
  
  
  
  
  
  
  
      """simple docstring"""
  
      def __init__( self    ,      *__snake_case    ,      **__snake_case					):
           snake_case					=       F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"					)					)} instead.'''
           deprecate('''cross_attention'''    ,      '''0.20.0'''    ,      __snake_case    ,      standard_warn=__snake_case					)
           super().__init__(*__snake_case    ,      **__snake_case					)
  
  
  
  
  