


import argparse
import json
import os

import fairseq
import torch
from fairseq.data import Dictionary

# Register SEW's fairseq modules
from sew_asapp import tasks  # noqa: F401

from transformers import (
    SEWConfig,
    SEWForCTC,
    SEWModel,
    WavaVecaCTCTokenizer,
    WavaVecaFeatureExtractor,
    WavaVecaProcessor,
    logging,
)


logging.set_verbosity_info()
_snake_case  :	List[Any]			      =       logging.get_logger(__name__)

_snake_case  :	Union[str, Any]			      =       {
    "post_extract_proj": "feature_projection",
    "encoder.pos_conv.0": "encoder.pos_conv_embed.conv",
    "self_attn.k_proj": "encoder.layers.*.attention.k_proj",
    "self_attn.v_proj": "encoder.layers.*.attention.v_proj",
    "self_attn.q_proj": "encoder.layers.*.attention.q_proj",
    "self_attn.out_proj": "encoder.layers.*.attention.out_proj",
    "self_attn_layer_norm": "encoder.layers.*.layer_norm",
    "fc1": "encoder.layers.*.feed_forward.intermediate_dense",
    "fc2": "encoder.layers.*.feed_forward.output_dense",
    "final_layer_norm": "encoder.layers.*.final_layer_norm",
    "encoder.upsample.0": "encoder.upsample.projection",
    "encoder.layer_norm": "encoder.layer_norm",
    "w2v_model.layer_norm": "layer_norm",
    "w2v_encoder.proj": "lm_head",
    "mask_emb": "masked_spec_embed",
}







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase			):
							for attribute in key.split("."			):
														__snake_case	:    Any											=     getattr(__A							,			__A			)

							if weight_type is not None:
														__snake_case	:    Optional[Any]											=     getattr(__A							,			__A			).shape
							else:
														__snake_case	:    Dict											=     hf_pointer.shape

							assert hf_shape == value.shape, (
							    F'Shape of hf {key + "." + weight_type if weight_type is not None else ""} is {hf_shape}, but should be'
							    F' {value.shape} for {full_name}'
							)

							if weight_type == "weight":
														__snake_case	:    Union[str, Any]											=     value
							elif weight_type == "weight_g":
														__snake_case	:    Tuple											=     value
							elif weight_type == "weight_v":
														__snake_case	:    List[Any]											=     value
							elif weight_type == "bias":
														__snake_case	:    List[str]											=     value
							else:
														__snake_case	:    Tuple											=     value

							logger.info(F'{key + "." + weight_type if weight_type is not None else ""} was initialized from {full_name}.'			)







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase			):
							__snake_case	:    Any											=     []
							__snake_case	:    Optional[int]											=     fairseq_model.state_dict()

							__snake_case	:    Any											=     hf_model.sew.feature_extractor if is_finetuned else hf_model.feature_extractor

							for name, value in fairseq_dict.items():
														__snake_case	:    str											=     False
														if "conv_layers" in name:
																					load_conv_layer(
																					    __A							,			__A							,			__A							,			__A							,			hf_model.config.feat_extract_norm == "group"							,			)
																					__snake_case	:    List[Any]											=     True
														else:
																					for key, mapped_key in MAPPING.items():
																												__snake_case	:    List[str]											=     "sew." + mapped_key if (is_finetuned and mapped_key != "lm_head") else mapped_key

																												if key in name or key.split("w2v_model."			)[-1] == name.split("."			)[0]:
																																			__snake_case	:    int											=     True
																																			if "*" in mapped_key:
																																										__snake_case	:    int											=     name.split(__A			)[0].split("."			)[-2]
																																										__snake_case	:    Any											=     mapped_key.replace("*"							,			__A			)
																																			if "weight_g" in name:
																																										__snake_case	:    Optional[int]											=     "weight_g"
																																			elif "weight_v" in name:
																																										__snake_case	:    str											=     "weight_v"
																																			elif "weight" in name:
																																										__snake_case	:    str											=     "weight"
																																			elif "bias" in name:
																																										__snake_case	:    str											=     "bias"
																																			else:
																																										__snake_case	:    Optional[Any]											=     None
																																			set_recursively(__A							,			__A							,			__A							,			__A							,			__A			)
																												continue
														if not is_used:
																					unused_weights.append(__A			)

							logger.warning(F'Unused weights: {unused_weights}'			)







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase			):
							__snake_case	:    int											=     full_name.split("conv_layers."			)[-1]
							__snake_case	:    int											=     name.split("."			)
							__snake_case	:    List[Any]											=     int(items[0]			)
							__snake_case	:    Tuple											=     int(items[1]			)

							if type_id == 0:
														if "bias" in name:
																					assert value.shape == feature_extractor.conv_layers[layer_id].conv.bias.data.shape, (
																					    F'{full_name} has size {value.shape}, but'
																					    F' {feature_extractor.conv_layers[layer_id].conv.bias.data.shape} was found.'
																					)
																					__snake_case	:    int											=     value
																					logger.info(F'Feat extract conv layer {layer_id} was initialized from {full_name}.'			)
														elif "weight" in name:
																					assert value.shape == feature_extractor.conv_layers[layer_id].conv.weight.data.shape, (
																					    F'{full_name} has size {value.shape}, but'
																					    F' {feature_extractor.conv_layers[layer_id].conv.weight.data.shape} was found.'
																					)
																					__snake_case	:    Optional[Any]											=     value
																					logger.info(F'Feat extract conv layer {layer_id} was initialized from {full_name}.'			)
							elif (type_id == 2 and not use_group_norm) or (type_id == 2 and layer_id == 0 and use_group_norm):
														if "bias" in name:
																					assert value.shape == feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape, (
																					    F'{full_name} has size {value.shape}, but {feature_extractor[layer_id].layer_norm.bias.data.shape} was'
																					    " found."
																					)
																					__snake_case	:    Tuple											=     value
																					logger.info(F'Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}.'			)
														elif "weight" in name:
																					assert value.shape == feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape, (
																					    F'{full_name} has size {value.shape}, but'
																					    F' {feature_extractor[layer_id].layer_norm.weight.data.shape} was found.'
																					)
																					__snake_case	:    Optional[int]											=     value
																					logger.info(F'Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}.'			)
							else:
														unused_weights.append(__A			)







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase			):
							__snake_case	:    List[Any]											=     SEWConfig()
							if is_finetuned:
														__snake_case	:    Dict											=     model.wav_encoder.wav_model.cfg
							else:
														__snake_case	:    int											=     model.cfg

							__snake_case	:    Union[str, Any]											=     fs_config.conv_bias
							__snake_case	:    Any											=     eval(fs_config.conv_feature_layers			)
							__snake_case	:    Any											=     [x[0] for x in conv_layers]
							__snake_case	:    int											=     [x[1] for x in conv_layers]
							__snake_case	:    List[Any]											=     [x[2] for x in conv_layers]
							__snake_case	:    Union[str, Any]											=     "gelu"
							__snake_case	:    Optional[int]											=     "layer" if fs_config.extractor_mode == "layer_norm" else "group"
							__snake_case	:    Optional[int]											=     0.0
							__snake_case	:    Dict											=     fs_config.activation_fn.name
							__snake_case	:    Dict											=     fs_config.encoder_embed_dim
							__snake_case	:    Tuple											=     0.0_2
							__snake_case	:    Optional[Any]											=     fs_config.encoder_ffn_embed_dim
							__snake_case	:    str											=     1e-5
							__snake_case	:    Any											=     fs_config.encoder_layerdrop
							__snake_case	:    Optional[Any]											=     fs_config.encoder_attention_heads
							__snake_case	:    Union[str, Any]											=     fs_config.conv_pos_groups
							__snake_case	:    Optional[int]											=     fs_config.conv_pos
							__snake_case	:    Any											=     len(__A			)
							__snake_case	:    Optional[Any]											=     fs_config.encoder_layers
							__snake_case	:    Union[str, Any]											=     fs_config.squeeze_factor

							# take care of any params that are overridden by the Wav2VecCtc model
							if is_finetuned:
														__snake_case	:    Dict											=     model.cfg
														__snake_case	:    Any											=     fs_config.final_dropout
														__snake_case	:    List[str]											=     fs_config.layerdrop
							__snake_case	:    Any											=     fs_config.activation_dropout
							__snake_case	:    Dict											=     fs_config.mask_prob > 0 or fs_config.mask_channel_prob > 0
							__snake_case	:    List[Any]											=     fs_config.attention_dropout
							__snake_case	:    Optional[Any]											=     fs_config.dropout_input
							__snake_case	:    int											=     fs_config.dropout
							__snake_case	:    Optional[Any]											=     fs_config.mask_channel_length
							__snake_case	:    Union[str, Any]											=     fs_config.mask_channel_prob
							__snake_case	:    Dict											=     fs_config.mask_length
							__snake_case	:    Union[str, Any]											=     fs_config.mask_prob

							__snake_case	:    Optional[Any]											=     "Wav2Vec2FeatureExtractor"
							__snake_case	:    Tuple											=     "Wav2Vec2CTCTokenizer"

							return config







@torch.no_grad()
def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase=None							,			__lowerCamelCase=None							,			__lowerCamelCase=True			):

							if is_finetuned:
														__snake_case				,    __snake_case				,    __snake_case	:    Any											=     fairseq.checkpoint_utils.load_model_ensemble_and_task(
														    [checkpoint_path]							,			arg_overrides={"data": "/".join(dict_path.split("/"			)[:-1]			)}			)
							else:
														__snake_case				,    __snake_case				,    __snake_case	:    str											=     fairseq.checkpoint_utils.load_model_ensemble_and_task([checkpoint_path]			)

							if config_path is not None:
														__snake_case	:    Tuple											=     SEWConfig.from_pretrained(__A			)
							else:
														__snake_case	:    List[Any]											=     convert_config(model[0]							,			__A			)
							__snake_case	:    int											=     model[0].eval()

							__snake_case	:    List[Any]											=     True if config.feat_extract_norm == "layer" else False
							__snake_case	:    int											=     WavaVecaFeatureExtractor(
							    feature_size=1							,			sampling_rate=1_6_0_0_0							,			padding_value=0							,			do_normalize=__A							,			return_attention_mask=__A							,			)

							if is_finetuned:
														if dict_path:
																					__snake_case	:    Any											=     Dictionary.load(__A			)

																					# important change bos & pad token id since CTC symbol is <pad> and
																					# not <s> as in fairseq
																					__snake_case	:    str											=     target_dict.pad_index
																					__snake_case	:    Tuple											=     target_dict.bos_index
																					__snake_case	:    Union[str, Any]											=     target_dict.pad_index
																					__snake_case	:    List[str]											=     target_dict.bos_index
																					__snake_case	:    Optional[Any]											=     target_dict.eos_index
																					__snake_case	:    List[Any]											=     len(target_dict.symbols			)
																					__snake_case	:    Union[str, Any]											=     os.path.join(__A							,			"vocab.json"			)
																					if not os.path.isdir(__A			):
																												logger.error("--pytorch_dump_folder_path ({}) should be a directory".format(__A			)			)
																												return
																					os.makedirs(__A							,			exist_ok=__A			)
																					with open(__A							,			"w"							,			encoding="utf-8"			) as vocab_handle:
																												json.dump(target_dict.indices							,			__A			)
																					__snake_case	:    str											=     WavaVecaCTCTokenizer(
																					    __A							,			unk_token=target_dict.unk_word							,			pad_token=target_dict.pad_word							,			bos_token=target_dict.bos_word							,			eos_token=target_dict.eos_word							,			word_delimiter_token="|"							,			do_lower_case=__A							,			)
																					__snake_case	:    Dict											=     WavaVecaProcessor(feature_extractor=__A							,			tokenizer=__A			)
																					processor.save_pretrained(__A			)

														__snake_case	:    str											=     SEWForCTC(__A			)
							else:
														__snake_case	:    List[str]											=     SEWModel(__A			)
														feature_extractor.save_pretrained(__A			)

							recursively_load_weights(__A							,			__A							,			__A			)

							hf_model.save_pretrained(__A			)


if __name__ == "__main__":
			_snake_case  :	Optional[int]			      =       argparse.ArgumentParser()
			parser.add_argument("--pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model.")
			parser.add_argument("--checkpoint_path", default=None, type=str, help="Path to fairseq checkpoint")
			parser.add_argument("--dict_path", default=None, type=str, help="Path to dict of fine-tuned model")
			parser.add_argument("--config_path", default=None, type=str, help="Path to hf config.json of model to convert")
			parser.add_argument(
			    "--is_finetuned", action="store_true", help="Whether the model to convert is a fine-tuned model or not"
			)
			_snake_case  :	str			      =       parser.parse_args()
			convert_sew_checkpoint(
			    args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path, args.dict_path, args.is_finetuned
			)





import gc
import random
import unittest

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

from diffusers import (
    AutoencoderKL,
    DiffusionPipeline,
    EulerDiscreteScheduler,
    StableDiffusionXLImgaImgPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import floats_tensor, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()

class        a	(_lowerCAmelCase  ,       _lowerCAmelCase  ,       unittest.TestCase   ):




							"""simple docstring"""


							__UpperCAmelCase					:							Optional[Any]  						=						StableDiffusionXLImgaImgPipeline
							__UpperCAmelCase					:							Any  						=						TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"height", "width"}
							__UpperCAmelCase					:							Dict  						=						PipelineTesterMixin.required_optional_params - {"latents"}
							__UpperCAmelCase					:							Union[str, Any]  						=						TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
							__UpperCAmelCase					:							Tuple  						=						IMAGE_TO_IMAGE_IMAGE_PARAMS
							__UpperCAmelCase					:							str  						=						IMAGE_TO_IMAGE_IMAGE_PARAMS

							def 					__snake_case      (							self :						Optional[Any]       )			->					Tuple:
														torch.manual_seed(0       )
														__snake_case	:    Optional[int]											=     UNetaDConditionModel(
														    block_out_channels=(32, 64)					,			layers_per_block=2					,			sample_size=32					,			in_channels=4					,			out_channels=4					,			down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")					,			up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")					,			attention_head_dim=(2, 4)					,			use_linear_projection=lowerCamelCase					,			addition_embed_type="text_time"					,			addition_time_embed_dim=8					,			transformer_layers_per_block=(1, 2)					,			projection_class_embeddings_input_dim=80					,			cross_attention_dim=64					,			)
														__snake_case	:    Tuple											=     EulerDiscreteScheduler(
														    beta_start=0.0_00_85					,			beta_end=0.0_12					,			steps_offset=1					,			beta_schedule="scaled_linear"					,			timestep_spacing="leading"					,			)
														torch.manual_seed(0       )
														__snake_case	:    int											=     AutoencoderKL(
														    block_out_channels=[32, 64]					,			in_channels=3					,			out_channels=3					,			down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]					,			up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]					,			latent_channels=4					,			sample_size=128					,			)
														torch.manual_seed(0       )
														__snake_case	:    Optional[int]											=     CLIPTextConfig(
														    bos_token_id=0					,			eos_token_id=2					,			hidden_size=32					,			intermediate_size=37					,			layer_norm_eps=1E-05					,			num_attention_heads=4					,			num_hidden_layers=5					,			pad_token_id=1					,			vocab_size=1000					,			hidden_act="gelu"					,			projection_dim=32					,			)
														__snake_case	:    List[str]											=     CLIPTextModel(lowerCamelCase       )
														__snake_case	:    Any											=     CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"					,			local_files_only=lowerCamelCase       )

														__snake_case	:    List[str]											=     CLIPTextModelWithProjection(lowerCamelCase       )
														__snake_case	:    List[Any]											=     CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"					,			local_files_only=lowerCamelCase       )

														__snake_case	:    Optional[int]											=     {
														    "unet": unet,
														    "scheduler": scheduler,
														    "vae": vae,
														    "text_encoder": text_encoder,
														    "tokenizer": tokenizer,
														    "text_encoder_2": text_encoder_a,
														    "tokenizer_2": tokenizer_a,
														    # "safety_checker": None,
														    # "feature_extractor": None,
														}
														return components

							def 					__snake_case      (							self :						Optional[Any]					,			lowerCamelCase :						List[Any]					,			lowerCamelCase :						List[Any]=0       )			->					Union[str, Any]:
														__snake_case	:    int											=     floats_tensor((1, 3, 32, 32)					,			rng=random.Random(lowerCamelCase       )       ).to(lowerCamelCase       )
														__snake_case	:    Any											=     image / 2 + 0.5
														if str(lowerCamelCase       ).startswith("mps"       ):
																					__snake_case	:    Dict											=     torch.manual_seed(lowerCamelCase       )
														else:
																					__snake_case	:    int											=     torch.Generator(device=lowerCamelCase       ).manual_seed(lowerCamelCase       )
														__snake_case	:    Optional[Any]											=     {
														    "prompt": "A painting of a squirrel eating a burger",
														    "image": image,
														    "generator": generator,
														    "num_inference_steps": 2,
														    "guidance_scale": 5.0,
														    "output_type": "numpy",
														    "strength": 0.75,
														}
														return inputs

							def 					__snake_case      (							self :						Dict       )			->					Any:
														__snake_case	:    Dict											=     "cpu"  # ensure determinism for the device-dependent torch.Generator
														__snake_case	:    Any											=     self.get_dummy_components()
														__snake_case	:    int											=     StableDiffusionXLImgaImgPipeline(**lowerCamelCase       )
														__snake_case	:    List[str]											=     sd_pipe.to(lowerCamelCase       )
														sd_pipe.set_progress_bar_config(disable=lowerCamelCase       )

														__snake_case	:    Tuple											=     self.get_dummy_inputs(lowerCamelCase       )
														__snake_case	:    Dict											=     sd_pipe(**lowerCamelCase       ).images
														__snake_case	:    Dict											=     image[0, -3:, -3:, -1]

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

														__snake_case	:    str											=     np.array([0.46_56, 0.48_40, 0.44_39, 0.66_98, 0.55_74, 0.45_24, 0.57_99, 0.59_43, 0.51_65]       )

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

							def 					__snake_case      (							self :						str       )			->					Optional[Any]:
														super().test_attention_slicing_forward_pass(expected_max_diff=3E-3       )

							def 					__snake_case      (							self :						Any       )			->					Dict:
														super().test_inference_batch_single_identical(expected_max_diff=3E-3       )

							def 					__snake_case      (							self :						str       )			->					Optional[int]:
														pass






							def 					__snake_case      (							self :						Tuple       )			->					Union[str, Any]:
														__snake_case	:    str											=     self.get_dummy_components()
														__snake_case	:    List[Any]											=     StableDiffusionXLImgaImgPipeline(**lowerCamelCase       )
														__snake_case	:    Optional[Any]											=     sd_pipe.to(lowerCamelCase       )
														__snake_case	:    int											=     sd_pipe.to(lowerCamelCase       )
														sd_pipe.set_progress_bar_config(disable=lowerCamelCase       )

														# forward without prompt embeds
														__snake_case	:    List[str]											=     self.get_dummy_inputs(lowerCamelCase       )
														__snake_case	:    str											=     3 * ["this is a negative prompt"]
														__snake_case	:    Any											=     negative_prompt
														__snake_case	:    Optional[Any]											=     3 * [inputs["prompt"]]

														__snake_case	:    int											=     sd_pipe(**lowerCamelCase       )
														__snake_case	:    List[Any]											=     output.images[0, -3:, -3:, -1]

														# forward with prompt embeds
														__snake_case	:    List[Any]											=     self.get_dummy_inputs(lowerCamelCase       )
														__snake_case	:    Optional[Any]											=     3 * ["this is a negative prompt"]
														__snake_case	:    int											=     3 * [inputs.pop("prompt"       )]

														(
														    (
														    __snake_case
														)				,    (
														    __snake_case
														)				,    (
														    __snake_case
														)				,    (
														    __snake_case
														)				,    
														)	:    Dict											=     sd_pipe.encode_prompt(lowerCamelCase					,			negative_prompt=lowerCamelCase       )

														__snake_case	:    Tuple											=     sd_pipe(
														    **lowerCamelCase					,			prompt_embeds=lowerCamelCase					,			negative_prompt_embeds=lowerCamelCase					,			pooled_prompt_embeds=lowerCamelCase					,			negative_pooled_prompt_embeds=lowerCamelCase					,			)
														__snake_case	:    List[str]											=     output.images[0, -3:, -3:, -1]

														# make sure that it's equal
														assert np.abs(image_slice_a.flatten() - image_slice_a.flatten()       ).max() < 1E-4

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




							"""simple docstring"""


							def 					__snake_case      (							self :						Optional[int]       )			->					Dict:
														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()

							def 					__snake_case      (							self :						Optional[Any]					,			lowerCamelCase :						Any					,			lowerCamelCase :						Optional[Any]="cpu"					,			lowerCamelCase :						str=torch.floataa					,			lowerCamelCase :						int=0       )			->					Dict:
														__snake_case	:    int											=     torch.Generator(device=lowerCamelCase       ).manual_seed(lowerCamelCase       )
														__snake_case	:    Optional[Any]											=     np.random.RandomState(lowerCamelCase       ).standard_normal((1, 4, 64, 64)       )
														__snake_case	:    Optional[Any]											=     torch.from_numpy(lowerCamelCase       ).to(device=lowerCamelCase					,			dtype=lowerCamelCase       )
														__snake_case	:    List[str]											=     {
														    "prompt": "a photograph of an astronaut riding a horse",
														    "latents": latents,
														    "generator": generator,
														    "num_inference_steps": 3,
														    "guidance_scale": 7.5,
														    "output_type": "numpy",
														}
														return inputs






							def 					__snake_case      (							self :						str       )			->					Any:
														__snake_case	:    List[str]											=     DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-base"       )
														pipe.to(lowerCamelCase       )
														pipe.set_progress_bar_config(disable=lowerCamelCase       )

														__snake_case	:    int											=     self.get_inputs(lowerCamelCase       )
														__snake_case	:    Optional[Any]											=     pipe(**lowerCamelCase       ).images
														__snake_case	:    Any											=     image[0, -3:, -3:, -1].flatten()

														assert image.shape == (1, 512, 512, 3)
														__snake_case	:    Optional[int]											=     np.array([0.4_94_93, 0.4_78_96, 0.4_07_98, 0.5_42_14, 0.5_32_12, 0.4_82_02, 0.4_76_56, 0.4_63_29, 0.4_85_06]       )
														assert np.abs(image_slice - expected_slice       ).max() < 7E-3

