


import importlib
import json
import os
from collections import OrderedDict
from typing import Dict, Optional, Union

# Build the list of all feature extractors
from ...configuration_utils import PretrainedConfig
from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code
from ...feature_extraction_utils import FeatureExtractionMixin
from ...utils import CONFIG_NAME, FEATURE_EXTRACTOR_NAME, get_file_from_repo, logging
from .auto_factory import _LazyAutoMapping
from .configuration_auto import (
    CONFIG_MAPPING_NAMES,
    AutoConfig,
    model_type_to_module_name,
    replace_list_option_in_docstrings,
)


SCREAMING_SNAKE_CASE			: str				   =					logging.get_logger(__name__)

SCREAMING_SNAKE_CASE			: int				   =					OrderedDict(
    [
        ("audio-spectrogram-transformer", "ASTFeatureExtractor"),
        ("beit", "BeitFeatureExtractor"),
        ("chinese_clip", "ChineseCLIPFeatureExtractor"),
        ("clap", "ClapFeatureExtractor"),
        ("clip", "CLIPFeatureExtractor"),
        ("clipseg", "ViTFeatureExtractor"),
        ("conditional_detr", "ConditionalDetrFeatureExtractor"),
        ("convnext", "ConvNextFeatureExtractor"),
        ("cvt", "ConvNextFeatureExtractor"),
        ("data2vec-audio", "Wav2Vec2FeatureExtractor"),
        ("data2vec-vision", "BeitFeatureExtractor"),
        ("deformable_detr", "DeformableDetrFeatureExtractor"),
        ("deit", "DeiTFeatureExtractor"),
        ("detr", "DetrFeatureExtractor"),
        ("dinat", "ViTFeatureExtractor"),
        ("donut-swin", "DonutFeatureExtractor"),
        ("dpt", "DPTFeatureExtractor"),
        ("encodec", "EncodecFeatureExtractor"),
        ("flava", "FlavaFeatureExtractor"),
        ("glpn", "GLPNFeatureExtractor"),
        ("groupvit", "CLIPFeatureExtractor"),
        ("hubert", "Wav2Vec2FeatureExtractor"),
        ("imagegpt", "ImageGPTFeatureExtractor"),
        ("layoutlmv2", "LayoutLMv2FeatureExtractor"),
        ("layoutlmv3", "LayoutLMv3FeatureExtractor"),
        ("levit", "LevitFeatureExtractor"),
        ("maskformer", "MaskFormerFeatureExtractor"),
        ("mctct", "MCTCTFeatureExtractor"),
        ("mobilenet_v1", "MobileNetV1FeatureExtractor"),
        ("mobilenet_v2", "MobileNetV2FeatureExtractor"),
        ("mobilevit", "MobileViTFeatureExtractor"),
        ("nat", "ViTFeatureExtractor"),
        ("owlvit", "OwlViTFeatureExtractor"),
        ("perceiver", "PerceiverFeatureExtractor"),
        ("poolformer", "PoolFormerFeatureExtractor"),
        ("regnet", "ConvNextFeatureExtractor"),
        ("resnet", "ConvNextFeatureExtractor"),
        ("segformer", "SegformerFeatureExtractor"),
        ("sew", "Wav2Vec2FeatureExtractor"),
        ("sew-d", "Wav2Vec2FeatureExtractor"),
        ("speech_to_text", "Speech2TextFeatureExtractor"),
        ("speecht5", "SpeechT5FeatureExtractor"),
        ("swiftformer", "ViTFeatureExtractor"),
        ("swin", "ViTFeatureExtractor"),
        ("swinv2", "ViTFeatureExtractor"),
        ("table-transformer", "DetrFeatureExtractor"),
        ("timesformer", "VideoMAEFeatureExtractor"),
        ("tvlt", "TvltFeatureExtractor"),
        ("unispeech", "Wav2Vec2FeatureExtractor"),
        ("unispeech-sat", "Wav2Vec2FeatureExtractor"),
        ("van", "ConvNextFeatureExtractor"),
        ("videomae", "VideoMAEFeatureExtractor"),
        ("vilt", "ViltFeatureExtractor"),
        ("vit", "ViTFeatureExtractor"),
        ("vit_mae", "ViTFeatureExtractor"),
        ("vit_msn", "ViTFeatureExtractor"),
        ("wav2vec2", "Wav2Vec2FeatureExtractor"),
        ("wav2vec2-conformer", "Wav2Vec2FeatureExtractor"),
        ("wavlm", "Wav2Vec2FeatureExtractor"),
        ("whisper", "WhisperFeatureExtractor"),
        ("xclip", "CLIPFeatureExtractor"),
        ("yolos", "YolosFeatureExtractor"),
    ]
)

SCREAMING_SNAKE_CASE			: Optional[int]				   =					_LazyAutoMapping(CONFIG_MAPPING_NAMES, FEATURE_EXTRACTOR_MAPPING_NAMES)



def 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[int]:
    for module_name, extractors in FEATURE_EXTRACTOR_MAPPING_NAMES.items():
        if class_name in extractors:
            _lowercase			:				Tuple 						=						model_type_to_module_name(lowerCamelCase_					)

            _lowercase			:				Optional[int] 						=						importlib.import_module(F'''.{module_name}'''				,					'transformers.models'					)
            try:
                return getattr(lowerCamelCase_				,					lowerCamelCase_					)
            except AttributeError:
                continue

    for _, extractor in FEATURE_EXTRACTOR_MAPPING._extra_content.items():
        if getattr(lowerCamelCase_				,					'__name__'				,					lowerCamelCase_					) == class_name:
            return extractor

    # We did not fine the class, but maybe it's because a dep is missing. In that case, the class will be in the main
    # init and we return the proper dummy to get an appropriate error message.
    _lowercase			:				str 						=						importlib.import_module('transformers'					)
    if hasattr(lowerCamelCase_				,					lowerCamelCase_					):
        return getattr(lowerCamelCase_				,					lowerCamelCase_					)

    return None



def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_ = None				,					lowerCamelCase_ = False				,					lowerCamelCase_ = False				,					lowerCamelCase_ = None				,					lowerCamelCase_ = None				,					lowerCamelCase_ = None				,					lowerCamelCase_ = False				,					**lowerCamelCase_				,					)       ->		Dict:
    _lowercase			:				List[Any] 						=						get_file_from_repo(
        lowerCamelCase_				,					lowerCamelCase_				,					cache_dir=lowerCamelCase_				,					force_download=lowerCamelCase_				,					resume_download=lowerCamelCase_				,					proxies=lowerCamelCase_				,					use_auth_token=lowerCamelCase_				,					revision=lowerCamelCase_				,					local_files_only=lowerCamelCase_				,					)
    if resolved_config_file is None:
        logger.info(
            'Could not locate the feature extractor configuration file, will try to use the model config instead.'					)
        return {}

    with open(lowerCamelCase_				,					encoding='utf-8'					) as reader:
        return json.load(lowerCamelCase_					)






class _lowerCamelCase:
       def __init__(   self)			->  Union[str, Any]:




           """simple docstring"""

           raise EnvironmentError(
               'AutoFeatureExtractor is designed to be instantiated '
               'using the `AutoFeatureExtractor.from_pretrained(pretrained_model_name_or_path)` method.')
       @classmethod
       @replace_list_option_in_docstrings(lowerCamelCase)
       def      UpperCamelCase	(   cls, lowerCamelCase, **lowerCamelCase)			->  int:




           """simple docstring"""

           _lowercase			:				str 						=						kwargs.pop('config', lowerCamelCase)
           _lowercase			:				List[Any] 						=						kwargs.pop('trust_remote_code', lowerCamelCase)
           _lowercase			:				List[Any] 						=						True

           _lowercase						,							_lowercase			:				List[str] 						=						FeatureExtractionMixin.get_feature_extractor_dict(lowerCamelCase, **lowerCamelCase)
           _lowercase			:				Tuple 						=						config_dict.get('feature_extractor_type', lowerCamelCase)
           _lowercase			:				List[Any] 						=						None
           if "AutoFeatureExtractor" in config_dict.get('auto_map', {}):
               _lowercase			:				Union[str, Any] 						=						config_dict['auto_map']['AutoFeatureExtractor']

           # If we don't find the feature extractor class in the feature extractor config, let's try the model config.
           if feature_extractor_class is None and feature_extractor_auto_map is None:
               if not isinstance(lowerCamelCase, lowerCamelCase):
                   _lowercase			:				Dict 						=						AutoConfig.from_pretrained(lowerCamelCase, **lowerCamelCase)
               # It could be in `config.feature_extractor_type``
               _lowercase			:				Optional[int] 						=						getattr(lowerCamelCase, 'feature_extractor_type', lowerCamelCase)
               if hasattr(lowerCamelCase, 'auto_map') and "AutoFeatureExtractor" in config.auto_map:
                   _lowercase			:				Union[str, Any] 						=						config.auto_map['AutoFeatureExtractor']

           if feature_extractor_class is not None:
               _lowercase			:				str 						=						feature_extractor_class_from_name(lowerCamelCase)

           _lowercase			:				Tuple 						=						feature_extractor_auto_map is not None
           _lowercase			:				int 						=						feature_extractor_class is not None or type(lowerCamelCase) in FEATURE_EXTRACTOR_MAPPING
           _lowercase			:				int 						=						resolve_trust_remote_code(
               lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase)

           if has_remote_code and trust_remote_code:
               _lowercase			:				Dict 						=						get_class_from_dynamic_module(
                   lowerCamelCase, lowerCamelCase, **lowerCamelCase)
               _lowercase			:				Optional[int] 						=						kwargs.pop('code_revision', lowerCamelCase)
               if os.path.isdir(lowerCamelCase):
                   feature_extractor_class.register_for_auto_class()
               return feature_extractor_class.from_dict(lowerCamelCase, **lowerCamelCase)
           elif feature_extractor_class is not None:
               return feature_extractor_class.from_dict(lowerCamelCase, **lowerCamelCase)
           # Last try: we use the FEATURE_EXTRACTOR_MAPPING.
           elif type(lowerCamelCase) in FEATURE_EXTRACTOR_MAPPING:
               _lowercase			:				str 						=						FEATURE_EXTRACTOR_MAPPING[type(lowerCamelCase)]
               return feature_extractor_class.from_dict(lowerCamelCase, **lowerCamelCase)

           raise ValueError(
               F'''Unrecognized feature extractor in {pretrained_model_name_or_path}. Should have a '''
               F'''`feature_extractor_type` key in its {FEATURE_EXTRACTOR_NAME} of {CONFIG_NAME}, or one of the following '''
               F'''`model_type` keys in its {CONFIG_NAME}: {", ".join(c for c in FEATURE_EXTRACTOR_MAPPING_NAMES.keys())}''')




       @staticmethod
       def      UpperCamelCase	(   lowerCamelCase, lowerCamelCase)			->  int:




           """simple docstring"""

           FEATURE_EXTRACTOR_MAPPING.register(lowerCamelCase, lowerCamelCase)





import os
import tempfile
import unittest

import numpy as np

from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import require_flax, slow


if is_flax_available():
      import jax
      import jax.numpy as jnp
      from flax.jax_utils import replicate
      from flax.training.common_utils import shard

      from diffusers import FlaxDDIMScheduler, FlaxDiffusionPipeline, FlaxStableDiffusionPipeline




@require_flax
class   UpperCamelCase			(  unittest.TestCase ):

    def UpperCamelCase      (      self			:   Tuple     ):

     """simple docstring"""






     with tempfile.TemporaryDirectory() as tmpdirname:
      # pipeline has Flax weights
      SCREAMING_SNAKE_CASE		    =      FlaxDiffusionPipeline.from_pretrained(
          'hf-internal-testing/tiny-stable-diffusion-pipe'				,     safety_checker=snake_case__				,     cache_dir=snake_case__     )

      SCREAMING_SNAKE_CASE		    =      [t[-1] for t in os.walk(os.path.join(snake_case__				,     os.listdir(snake_case__     )[0]				,     'snapshots'     )     )]
      SCREAMING_SNAKE_CASE		    =      [item for sublist in all_root_files for item in sublist]

      # None of the downloaded files should be a PyTorch file even if we have some here:
      # https://huggingface.co/hf-internal-testing/tiny-stable-diffusion-pipe/blob/main/unet/diffusion_pytorch_model.bin
      assert not any(f.endswith('.bin'     ) for f in files     )




@slow
@require_flax
class   UpperCamelCase			(  unittest.TestCase ):

    def UpperCamelCase      (      self			:   Optional[Any]     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'hf-internal-testing/tiny-stable-diffusion-pipe'				,     safety_checker=snake_case__     )

     SCREAMING_SNAKE_CASE		    =      (
         'A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of'
         ' field, close up, split lighting, cinematic'
     )

     SCREAMING_SNAKE_CASE		    =      jax.random.PRNGKey(0     )
     SCREAMING_SNAKE_CASE		    =      4

     SCREAMING_SNAKE_CASE		    =      jax.device_count()
     SCREAMING_SNAKE_CASE		    =      num_samples * [prompt]
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )

     # shard inputs and rng
     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      jax.random.split(snake_case__				,     snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )

     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images

     assert images.shape == (num_samples, 1, 6_4, 6_4, 3)
     if jax.device_count() == 8:
      assert np.abs(np.abs(images[0, 0, :2, :2, -2:]				,     dtype=np.floataa     ).sum() - 4.1_514_745     ) < 1E-3
      assert np.abs(np.abs(snake_case__				,     dtype=np.floataa     ).sum() - 49_947.875     ) < 5E-1

     SCREAMING_SNAKE_CASE		    =      pipeline.numpy_to_pil(np.asarray(images.reshape((num_samples,) + images.shape[-3:]     )     )     )
     assert len(snake_case__     ) == num_samples

    def UpperCamelCase      (      self			:   Union[str, Any]     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'CompVis/stable-diffusion-v1-4'				,     revision='flax'				,     safety_checker=snake_case__     )

     SCREAMING_SNAKE_CASE		    =      (
         'A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of'
         ' field, close up, split lighting, cinematic'
     )

     SCREAMING_SNAKE_CASE		    =      jax.random.PRNGKey(0     )
     SCREAMING_SNAKE_CASE		    =      5_0

     SCREAMING_SNAKE_CASE		    =      jax.device_count()
     SCREAMING_SNAKE_CASE		    =      num_samples * [prompt]
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )

     # shard inputs and rng
     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      jax.random.split(snake_case__				,     snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )

     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images

     assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
     if jax.device_count() == 8:
      assert np.abs((np.abs(images[0, 0, :2, :2, -2:]				,     dtype=np.floataa     ).sum() - 0.05_652_401)     ) < 1E-3
      assert np.abs((np.abs(snake_case__				,     dtype=np.floataa     ).sum() - 2_383_808.2)     ) < 5E-1

    def UpperCamelCase      (      self			:   Optional[Any]     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'CompVis/stable-diffusion-v1-4'				,     revision='bf16'				,     dtype=jnp.bfloataa				,     safety_checker=snake_case__     )

     SCREAMING_SNAKE_CASE		    =      (
         'A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of'
         ' field, close up, split lighting, cinematic'
     )

     SCREAMING_SNAKE_CASE		    =      jax.random.PRNGKey(0     )
     SCREAMING_SNAKE_CASE		    =      5_0

     SCREAMING_SNAKE_CASE		    =      jax.device_count()
     SCREAMING_SNAKE_CASE		    =      num_samples * [prompt]
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )

     # shard inputs and rng
     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      jax.random.split(snake_case__				,     snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )

     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images

     assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
     if jax.device_count() == 8:
      assert np.abs((np.abs(images[0, 0, :2, :2, -2:]				,     dtype=np.floataa     ).sum() - 0.04_003_906)     ) < 1E-3
      assert np.abs((np.abs(snake_case__				,     dtype=np.floataa     ).sum() - 2_373_516.75)     ) < 5E-1

    def UpperCamelCase      (      self			:   List[Any]     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'CompVis/stable-diffusion-v1-4'				,     revision='bf16'				,     dtype=jnp.bfloataa     )

     SCREAMING_SNAKE_CASE		    =      (
         'A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of'
         ' field, close up, split lighting, cinematic'
     )

     SCREAMING_SNAKE_CASE		    =      jax.random.PRNGKey(0     )
     SCREAMING_SNAKE_CASE		    =      5_0

     SCREAMING_SNAKE_CASE		    =      jax.device_count()
     SCREAMING_SNAKE_CASE		    =      num_samples * [prompt]
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )

     # shard inputs and rng
     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      jax.random.split(snake_case__				,     snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )

     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images

     assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
     if jax.device_count() == 8:
      assert np.abs((np.abs(images[0, 0, :2, :2, -2:]				,     dtype=np.floataa     ).sum() - 0.04_003_906)     ) < 1E-3
      assert np.abs((np.abs(snake_case__				,     dtype=np.floataa     ).sum() - 2_373_516.75)     ) < 5E-1

    def UpperCamelCase      (      self			:   Dict     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE		    =      FlaxDDIMScheduler(
         beta_start=0.00_085				,     beta_end=0.012				,     beta_schedule='scaled_linear'				,     set_alpha_to_one=snake_case__				,     steps_offset=1				,     )

     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'CompVis/stable-diffusion-v1-4'				,     revision='bf16'				,     dtype=jnp.bfloataa				,     scheduler=snake_case__				,     safety_checker=snake_case__				,     )
     SCREAMING_SNAKE_CASE		    =      scheduler.create_state()

     SCREAMING_SNAKE_CASE		    =      scheduler_state

     SCREAMING_SNAKE_CASE		    =      (
         'A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of'
         ' field, close up, split lighting, cinematic'
     )

     SCREAMING_SNAKE_CASE		    =      jax.random.PRNGKey(0     )
     SCREAMING_SNAKE_CASE		    =      5_0

     SCREAMING_SNAKE_CASE		    =      jax.device_count()
     SCREAMING_SNAKE_CASE		    =      num_samples * [prompt]
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )

     # shard inputs and rng
     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      jax.random.split(snake_case__				,     snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )

     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images

     assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
     if jax.device_count() == 8:
      assert np.abs((np.abs(images[0, 0, :2, :2, -2:]				,     dtype=np.floataa     ).sum() - 0.045_043_945)     ) < 1E-3
      assert np.abs((np.abs(snake_case__				,     dtype=np.floataa     ).sum() - 2_347_693.5)     ) < 5E-1




    def UpperCamelCase      (      self			:   Tuple     ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE		    =      (
         'A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of'
         ' field, close up, split lighting, cinematic'
     )

     SCREAMING_SNAKE_CASE		    =      jax.device_count()
     SCREAMING_SNAKE_CASE		    =      num_samples * [prompt]
     SCREAMING_SNAKE_CASE		    =      jax.random.split(jax.random.PRNGKey(0     )				,     snake_case__     )

     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'CompVis/stable-diffusion-v1-4'				,     revision='bf16'				,     dtype=jnp.bfloataa				,     safety_checker=snake_case__				,     )

     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images
     assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
     SCREAMING_SNAKE_CASE		    =      images[2, 0, 2_5_6, 1_0:1_7, 1]

     # With memory efficient attention
     SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      FlaxStableDiffusionPipeline.from_pretrained(
         'CompVis/stable-diffusion-v1-4'				,     revision='bf16'				,     dtype=jnp.bfloataa				,     safety_checker=snake_case__				,     use_memory_efficient_attention=snake_case__				,     )

     SCREAMING_SNAKE_CASE		    =      replicate(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      pipeline.prepare_inputs(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      shard(snake_case__     )
     SCREAMING_SNAKE_CASE		    =      pipeline(snake_case__				,     snake_case__				,     snake_case__				,     jit=snake_case__     ).images
     assert images_eff.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
     SCREAMING_SNAKE_CASE		    =      images[2, 0, 2_5_6, 1_0:1_7, 1]

     # I checked the results visually and they are very similar. However, I saw that the max diff is `1` and the `sum`
     # over the 8 images is exactly `256`, which is very suspicious. Testing a random slice for now.
     assert abs(slice_eff - slice     ).max() < 1E-2

