




import unittest

from transformers import (
    MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
    Pipeline,
    ZeroShotClassificationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow

from .test_pipelines_common import ANY


# These 2 model types require different inputs than those of the usual text models.
_lowerCamelCase      			=						{'LayoutLMv2Config', 'LayoutLMv3Config'}



@is_pipeline_test
class       a					(       unittest.TestCase      ):

     '''simple docstring'''





     lowerCAmelCase    :	int       		=  MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
     lowerCAmelCase    :	Dict       		=  TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING

     if model_mapping is not None:
          lowerCAmelCase    :	Optional[int]       		=  {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
     if tf_model_mapping is not None:
          lowerCAmelCase    :	List[str]       		=  {
              config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
          }
     def   lowerCamelCase_       (     self       :      Dict ,   __snake_case       :      Optional[int] ,   __snake_case       :      Tuple ,   __snake_case       :      Tuple    ):
         UpperCAmelCase_										=					ZeroShotClassificationPipeline(
             model=__snake_case ,   tokenizer=__snake_case ,   candidate_labels=['''polics''', '''health''']    )
         return classifier, ["Who are you voting for in 2020?", "My stomach hurts."]
     def   lowerCamelCase_       (     self       :      List[str] ,   __snake_case       :      Union[str, Any] ,   __snake_case       :      Optional[Any]    ):
         UpperCAmelCase_										=					classifier('''Who are you voting for in 2020?''' ,   candidate_labels='''politics'''    )
         self.assertEqual(__snake_case ,   {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    )], '''scores''': [ANY(__snake_case    )]}    )

         # No kwarg
         UpperCAmelCase_										=					classifier('''Who are you voting for in 2020?''' ,   ['''politics''']    )
         self.assertEqual(__snake_case ,   {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    )], '''scores''': [ANY(__snake_case    )]}    )

         UpperCAmelCase_										=					classifier('''Who are you voting for in 2020?''' ,   candidate_labels=['''politics''']    )
         self.assertEqual(__snake_case ,   {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    )], '''scores''': [ANY(__snake_case    )]}    )

         UpperCAmelCase_										=					classifier('''Who are you voting for in 2020?''' ,   candidate_labels='''politics, public health'''    )
         self.assertEqual(
             __snake_case ,   {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    ), ANY(__snake_case    )], '''scores''': [ANY(__snake_case    ), ANY(__snake_case    )]}    )
         self.assertAlmostEqual(sum(nested_simplify(outputs['''scores''']    )    ) ,   1.0    )

         UpperCAmelCase_										=					classifier('''Who are you voting for in 2020?''' ,   candidate_labels=['''politics''', '''public health''']    )
         self.assertEqual(
             __snake_case ,   {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    ), ANY(__snake_case    )], '''scores''': [ANY(__snake_case    ), ANY(__snake_case    )]}    )
         self.assertAlmostEqual(sum(nested_simplify(outputs['''scores''']    )    ) ,   1.0    )

         UpperCAmelCase_										=					classifier(
             '''Who are you voting for in 2020?''' ,   candidate_labels='''politics''' ,   hypothesis_template='''This text is about {}'''    )
         self.assertEqual(__snake_case ,   {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    )], '''scores''': [ANY(__snake_case    )]}    )

         # https://github.com/huggingface/transformers/issues/13846
         UpperCAmelCase_										=					classifier(['''I am happy'''] ,   ['''positive''', '''negative''']    )
         self.assertEqual(
             __snake_case ,   [
                 {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    ), ANY(__snake_case    )], '''scores''': [ANY(__snake_case    ), ANY(__snake_case    )]}
                 for i in range(1    )
             ] ,   )
         UpperCAmelCase_										=					classifier(['''I am happy''', '''I am sad'''] ,   ['''positive''', '''negative''']    )
         self.assertEqual(
             __snake_case ,   [
                 {'''sequence''': ANY(__snake_case    ), '''labels''': [ANY(__snake_case    ), ANY(__snake_case    )], '''scores''': [ANY(__snake_case    ), ANY(__snake_case    )]}
                 for i in range(2    )
             ] ,   )

         with self.assertRaises(__snake_case    ):
             classifier('''''' ,   candidate_labels='''politics'''    )

         with self.assertRaises(__snake_case    ):
             classifier(__snake_case ,   candidate_labels='''politics'''    )

         with self.assertRaises(__snake_case    ):
             classifier('''Who are you voting for in 2020?''' ,   candidate_labels=''''''    )

         with self.assertRaises(__snake_case    ):
             classifier('''Who are you voting for in 2020?''' ,   candidate_labels=__snake_case    )

         with self.assertRaises(__snake_case    ):
             classifier(
                 '''Who are you voting for in 2020?''' ,   candidate_labels='''politics''' ,   hypothesis_template='''Not formatting template''' ,   )

         with self.assertRaises(__snake_case    ):
             classifier(
                 '''Who are you voting for in 2020?''' ,   candidate_labels='''politics''' ,   hypothesis_template=__snake_case ,   )

         self.run_entailment_id(__snake_case    )
     def   lowerCamelCase_       (     self       :      Dict ,   __snake_case       :      Pipeline    ):
         UpperCAmelCase_										=					zero_shot_classifier.model.config
         UpperCAmelCase_										=					config.labelaid
         UpperCAmelCase_										=					zero_shot_classifier.entailment_id

         UpperCAmelCase_										=					{'''LABEL_0''': 0, '''LABEL_1''': 1, '''LABEL_2''': 2}
         self.assertEqual(zero_shot_classifier.entailment_id ,   -1    )

         UpperCAmelCase_										=					{'''entailment''': 0, '''neutral''': 1, '''contradiction''': 2}
         self.assertEqual(zero_shot_classifier.entailment_id ,   0    )

         UpperCAmelCase_										=					{'''ENTAIL''': 0, '''NON-ENTAIL''': 1}
         self.assertEqual(zero_shot_classifier.entailment_id ,   0    )

         UpperCAmelCase_										=					{'''ENTAIL''': 2, '''NEUTRAL''': 1, '''CONTR''': 0}
         self.assertEqual(zero_shot_classifier.entailment_id ,   2    )

         UpperCAmelCase_										=					original_labelaid
         self.assertEqual(__snake_case ,   zero_shot_classifier.entailment_id    )
     @require_torch
     def   lowerCamelCase_       (     self       :      Union[str, Any]    ):
         UpperCAmelCase_										=					pipeline(
             '''zero-shot-classification''' ,   model='''sshleifer/tiny-distilbert-base-cased-distilled-squad''' ,   framework='''pt''' ,   )
         # There was a regression in 4.10 for this
         # Adding a test so we don't make the mistake again.
         # https://github.com/huggingface/transformers/issues/13381#issuecomment-912343499
         zero_shot_classifier(
             '''Who are you voting for in 2020?''' * 1_00 ,   candidate_labels=['''politics''', '''public health''', '''science''']    )
     @require_torch
     def   lowerCamelCase_       (     self       :      List[str]    ):
         UpperCAmelCase_										=					pipeline(
             '''zero-shot-classification''' ,   model='''sshleifer/tiny-distilbert-base-cased-distilled-squad''' ,   framework='''pt''' ,   )
         UpperCAmelCase_										=					zero_shot_classifier(
             '''Who are you voting for in 2020?''' ,   candidate_labels=['''politics''', '''public health''', '''science''']    )

         self.assertEqual(
             nested_simplify(__snake_case    ) ,   {
                 '''sequence''': '''Who are you voting for in 2020?''',
                 '''labels''': ['''science''', '''public health''', '''politics'''],
                 '''scores''': [0.333, 0.333, 0.333],
             } ,   )
     @require_tf
     def   lowerCamelCase_       (     self       :      Tuple    ):
         UpperCAmelCase_										=					pipeline(
             '''zero-shot-classification''' ,   model='''sshleifer/tiny-distilbert-base-cased-distilled-squad''' ,   framework='''tf''' ,   )
         UpperCAmelCase_										=					zero_shot_classifier(
             '''Who are you voting for in 2020?''' ,   candidate_labels=['''politics''', '''public health''', '''science''']    )

         self.assertEqual(
             nested_simplify(__snake_case    ) ,   {
                 '''sequence''': '''Who are you voting for in 2020?''',
                 '''labels''': ['''science''', '''public health''', '''politics'''],
                 '''scores''': [0.333, 0.333, 0.333],
             } ,   )
     @slow
     @require_torch
     def   lowerCamelCase_       (     self       :      str    ):
         UpperCAmelCase_										=					pipeline('''zero-shot-classification''' ,   model='''roberta-large-mnli''' ,   framework='''pt'''    )
         UpperCAmelCase_										=					zero_shot_classifier(
             '''Who are you voting for in 2020?''' ,   candidate_labels=['''politics''', '''public health''', '''science''']    )

         self.assertEqual(
             nested_simplify(__snake_case    ) ,   {
                 '''sequence''': '''Who are you voting for in 2020?''',
                 '''labels''': ['''politics''', '''public health''', '''science'''],
                 '''scores''': [0.976, 0.015, 0.009],
             } ,   )
         UpperCAmelCase_										=					zero_shot_classifier(
             '''The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'''
             ''' in an encoder-decoder configuration. The best performing models also connect the encoder and decoder'''
             ''' through an attention mechanism. We propose a new simple network architecture, the Transformer, based'''
             ''' solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two'''
             ''' machine translation tasks show these models to be superior in quality while being more parallelizable'''
             ''' and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014'''
             ''' English-to-German translation task, improving over the existing best results, including ensembles by'''
             ''' over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new'''
             ''' single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small'''
             ''' fraction of the training costs of the best models from the literature. We show that the Transformer'''
             ''' generalizes well to other tasks by applying it successfully to English constituency parsing both with'''
             ''' large and limited training data.''' ,   candidate_labels=['''machine learning''', '''statistics''', '''translation''', '''vision'''] ,   multi_label=__snake_case ,   )
         self.assertEqual(
             nested_simplify(__snake_case    ) ,   {
                 '''sequence''': (
                     '''The dominant sequence transduction models are based on complex recurrent or convolutional neural'''
                     ''' networks in an encoder-decoder configuration. The best performing models also connect the'''
                     ''' encoder and decoder through an attention mechanism. We propose a new simple network'''
                     ''' architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence'''
                     ''' and convolutions entirely. Experiments on two machine translation tasks show these models to be'''
                     ''' superior in quality while being more parallelizable and requiring significantly less time to'''
                     ''' train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task,'''
                     ''' improving over the existing best results, including ensembles by over 2 BLEU. On the WMT 2014'''
                     ''' English-to-French translation task, our model establishes a new single-model state-of-the-art'''
                     ''' BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training'''
                     ''' costs of the best models from the literature. We show that the Transformer generalizes well to'''
                     ''' other tasks by applying it successfully to English constituency parsing both with large and'''
                     ''' limited training data.'''
                 ),
                 '''labels''': ['''translation''', '''machine learning''', '''vision''', '''statistics'''],
                 '''scores''': [0.817, 0.713, 0.018, 0.018],
             } ,   )




     @slow
     @require_tf
     def   lowerCamelCase_       (     self       :      Any    ):
         UpperCAmelCase_										=					pipeline('''zero-shot-classification''' ,   model='''roberta-large-mnli''' ,   framework='''tf'''    )
         UpperCAmelCase_										=					zero_shot_classifier(
             '''Who are you voting for in 2020?''' ,   candidate_labels=['''politics''', '''public health''', '''science''']    )

         self.assertEqual(
             nested_simplify(__snake_case    ) ,   {
                 '''sequence''': '''Who are you voting for in 2020?''',
                 '''labels''': ['''politics''', '''public health''', '''science'''],
                 '''scores''': [0.976, 0.015, 0.009],
             } ,   )
         UpperCAmelCase_										=					zero_shot_classifier(
             '''The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'''
             ''' in an encoder-decoder configuration. The best performing models also connect the encoder and decoder'''
             ''' through an attention mechanism. We propose a new simple network architecture, the Transformer, based'''
             ''' solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two'''
             ''' machine translation tasks show these models to be superior in quality while being more parallelizable'''
             ''' and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014'''
             ''' English-to-German translation task, improving over the existing best results, including ensembles by'''
             ''' over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new'''
             ''' single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small'''
             ''' fraction of the training costs of the best models from the literature. We show that the Transformer'''
             ''' generalizes well to other tasks by applying it successfully to English constituency parsing both with'''
             ''' large and limited training data.''' ,   candidate_labels=['''machine learning''', '''statistics''', '''translation''', '''vision'''] ,   multi_label=__snake_case ,   )
         self.assertEqual(
             nested_simplify(__snake_case    ) ,   {
                 '''sequence''': (
                     '''The dominant sequence transduction models are based on complex recurrent or convolutional neural'''
                     ''' networks in an encoder-decoder configuration. The best performing models also connect the'''
                     ''' encoder and decoder through an attention mechanism. We propose a new simple network'''
                     ''' architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence'''
                     ''' and convolutions entirely. Experiments on two machine translation tasks show these models to be'''
                     ''' superior in quality while being more parallelizable and requiring significantly less time to'''
                     ''' train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task,'''
                     ''' improving over the existing best results, including ensembles by over 2 BLEU. On the WMT 2014'''
                     ''' English-to-French translation task, our model establishes a new single-model state-of-the-art'''
                     ''' BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training'''
                     ''' costs of the best models from the literature. We show that the Transformer generalizes well to'''
                     ''' other tasks by applying it successfully to English constituency parsing both with large and'''
                     ''' limited training data.'''
                 ),
                 '''labels''': ['''translation''', '''machine learning''', '''vision''', '''statistics'''],
                 '''scores''': [0.817, 0.713, 0.018, 0.018],
             } ,   )











import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel
from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings
from diffusers.utils import load_numpy, slow, torch_device
from diffusers.utils.testing_utils import require_torch_gpu


_lowerCamelCase      			=						False



class       a					(       unittest.TestCase      ):

     '''simple docstring'''





     def   lowerCamelCase_       (     self       :      str    ):
         # clean up the VRAM after each test
         super().tearDown()
         gc.collect()
         torch.cuda.empty_cache()
     @property
     def   lowerCamelCase_       (     self       :      Any    ):
         return 12
     @property
     def   lowerCamelCase_       (     self       :      Union[str, Any]    ):
         return 12
     @property
     def   lowerCamelCase_       (     self       :      Optional[Any]    ):
         return 32
     @property
     def   lowerCamelCase_       (     self       :      List[Any]    ):
         torch.manual_seed(0    )
         UpperCAmelCase_										=					VQModel(
             block_out_channels=[32, 64] ,   in_channels=3 ,   out_channels=3 ,   down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D'''] ,   up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D'''] ,   latent_channels=3 ,   num_vq_embeddings=self.num_embed ,   vq_embed_dim=3 ,   )
         return model
     @property
     def   lowerCamelCase_       (     self       :      Tuple    ):
         UpperCAmelCase_										=					CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''    )
         return tokenizer
     @property
     def   lowerCamelCase_       (     self       :      int    ):
         torch.manual_seed(0    )
         UpperCAmelCase_										=					CLIPTextConfig(
             bos_token_id=0 ,   eos_token_id=2 ,   hidden_size=self.text_embedder_hidden_size ,   intermediate_size=37 ,   layer_norm_eps=1E-05 ,   num_attention_heads=4 ,   num_hidden_layers=5 ,   pad_token_id=1 ,   vocab_size=10_00 ,   )
         return CLIPTextModel(__snake_case    )
     @property
     def   lowerCamelCase_       (     self       :      Union[str, Any]    ):
         torch.manual_seed(0    )

         UpperCAmelCase_										=					12
         UpperCAmelCase_										=					12

         UpperCAmelCase_										=					{
             '''attention_bias''': True,
             '''cross_attention_dim''': 32,
             '''attention_head_dim''': height * width,
             '''num_attention_heads''': 1,
             '''num_vector_embeds''': self.num_embed,
             '''num_embeds_ada_norm''': self.num_embeds_ada_norm,
             '''norm_num_groups''': 32,
             '''sample_size''': width,
             '''activation_fn''': '''geglu-approximate''',
         }

         UpperCAmelCase_										=					TransformeraDModel(**__snake_case    )
         return model
     def   lowerCamelCase_       (     self       :      int    ):
         UpperCAmelCase_										=					'''cpu'''

         UpperCAmelCase_										=					self.dummy_vqvae
         UpperCAmelCase_										=					self.dummy_text_encoder
         UpperCAmelCase_										=					self.dummy_tokenizer
         UpperCAmelCase_										=					self.dummy_transformer
         UpperCAmelCase_										=					VQDiffusionScheduler(self.num_embed    )
         UpperCAmelCase_										=					LearnedClassifierFreeSamplingEmbeddings(learnable=__snake_case    )

         UpperCAmelCase_										=					VQDiffusionPipeline(
             vqvae=__snake_case ,   text_encoder=__snake_case ,   tokenizer=__snake_case ,   transformer=__snake_case ,   scheduler=__snake_case ,   learned_classifier_free_sampling_embeddings=__snake_case ,   )
         UpperCAmelCase_										=					pipe.to(__snake_case    )
         pipe.set_progress_bar_config(disable=__snake_case    )

         UpperCAmelCase_										=					'''teddy bear playing in the pool'''

         UpperCAmelCase_										=					torch.Generator(device=__snake_case    ).manual_seed(0    )
         UpperCAmelCase_										=					pipe([prompt] ,   generator=__snake_case ,   num_inference_steps=2 ,   output_type='''np'''    )
         UpperCAmelCase_										=					output.images

         UpperCAmelCase_										=					torch.Generator(device=__snake_case    ).manual_seed(0    )
         UpperCAmelCase_										=					pipe(
             [prompt] ,   generator=__snake_case ,   output_type='''np''' ,   return_dict=__snake_case ,   num_inference_steps=2    )[0]

         UpperCAmelCase_										=					image[0, -3:, -3:, -1]
         UpperCAmelCase_										=					image_from_tuple[0, -3:, -3:, -1]

         assert image.shape == (1, 24, 24, 3)

         UpperCAmelCase_										=					np.array([0.6_551, 0.6_168, 0.5_008, 0.5_676, 0.5_659, 0.4_295, 0.6_073, 0.5_599, 0.4_992]    )

         assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-2
         assert np.abs(image_from_tuple_slice.flatten() - expected_slice    ).max() < 1E-2




     def   lowerCamelCase_       (     self       :      str    ):
         UpperCAmelCase_										=					'''cpu'''

         UpperCAmelCase_										=					self.dummy_vqvae
         UpperCAmelCase_										=					self.dummy_text_encoder
         UpperCAmelCase_										=					self.dummy_tokenizer
         UpperCAmelCase_										=					self.dummy_transformer
         UpperCAmelCase_										=					VQDiffusionScheduler(self.num_embed    )
         UpperCAmelCase_										=					LearnedClassifierFreeSamplingEmbeddings(
             learnable=__snake_case ,   hidden_size=self.text_embedder_hidden_size ,   length=tokenizer.model_max_length    )

         UpperCAmelCase_										=					VQDiffusionPipeline(
             vqvae=__snake_case ,   text_encoder=__snake_case ,   tokenizer=__snake_case ,   transformer=__snake_case ,   scheduler=__snake_case ,   learned_classifier_free_sampling_embeddings=__snake_case ,   )
         UpperCAmelCase_										=					pipe.to(__snake_case    )
         pipe.set_progress_bar_config(disable=__snake_case    )

         UpperCAmelCase_										=					'''teddy bear playing in the pool'''

         UpperCAmelCase_										=					torch.Generator(device=__snake_case    ).manual_seed(0    )
         UpperCAmelCase_										=					pipe([prompt] ,   generator=__snake_case ,   num_inference_steps=2 ,   output_type='''np'''    )
         UpperCAmelCase_										=					output.images

         UpperCAmelCase_										=					torch.Generator(device=__snake_case    ).manual_seed(0    )
         UpperCAmelCase_										=					pipe(
             [prompt] ,   generator=__snake_case ,   output_type='''np''' ,   return_dict=__snake_case ,   num_inference_steps=2    )[0]

         UpperCAmelCase_										=					image[0, -3:, -3:, -1]
         UpperCAmelCase_										=					image_from_tuple[0, -3:, -3:, -1]

         assert image.shape == (1, 24, 24, 3)

         UpperCAmelCase_										=					np.array([0.6_693, 0.6_075, 0.4_959, 0.5_701, 0.5_583, 0.4_333, 0.6_171, 0.5_684, 0.4_988]    )

         assert np.abs(image_slice.flatten() - expected_slice    ).max() < 2.0
         assert np.abs(image_from_tuple_slice.flatten() - expected_slice    ).max() < 1E-2



@slow
@require_torch_gpu
class       a					(       unittest.TestCase      ):

     '''simple docstring'''





     def   lowerCamelCase_       (     self       :      Optional[int]    ):
         # clean up the VRAM after each test
         super().tearDown()
         gc.collect()
         torch.cuda.empty_cache()




     def   lowerCamelCase_       (     self       :      Optional[int]    ):
         UpperCAmelCase_										=					load_numpy(
             '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
             '''/vq_diffusion/teddy_bear_pool_classifier_free_sampling.npy'''    )

         UpperCAmelCase_										=					VQDiffusionPipeline.from_pretrained('''microsoft/vq-diffusion-ithq'''    )
         UpperCAmelCase_										=					pipeline.to(__snake_case    )
         pipeline.set_progress_bar_config(disable=__snake_case    )

         # requires GPU generator for gumbel softmax
         # don't use GPU generator in tests though
         UpperCAmelCase_										=					torch.Generator(device=__snake_case    ).manual_seed(0    )
         UpperCAmelCase_										=					pipeline(
             '''teddy bear playing in the pool''' ,   num_images_per_prompt=1 ,   generator=__snake_case ,   output_type='''np''' ,   )

         UpperCAmelCase_										=					output.images[0]

         assert image.shape == (2_56, 2_56, 3)
         assert np.abs(expected_image - image    ).max() < 2.0





