



'''simple docstring'''

import gc
import random
import unittest

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

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionInstructPixaPixPipeline,
    UNetaDConditionModel,
)
from diffusers.image_processor import VaeImageProcessor
from diffusers.utils import floats_tensor, load_image, 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_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()

class 	__magic_name__						(    _UpperCamelCase			,						_UpperCamelCase			,						_UpperCamelCase			,						unittest.TestCase   ):
							lowerCAmelCase       :    Any   				=					StableDiffusionInstructPixaPixPipeline
							lowerCAmelCase       :    Union[str, Any]   				=					TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'height', 'width', 'cross_attention_kwargs'}
							lowerCAmelCase       :    List[str]   				=					TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
							lowerCAmelCase       :    List[str]   				=					IMAGE_TO_IMAGE_IMAGE_PARAMS
							lowerCAmelCase       :    Optional[int]   				=					IMAGE_TO_IMAGE_IMAGE_PARAMS







							def 							__lowercase			(							self					:       List[str]		):
									torch.manual_seed(0		)
									_a     :      Any        =							UNetaDConditionModel(
									    block_out_channels=(32, 64)	,layers_per_block=2	,sample_size=32	,in_channels=8	,out_channels=4	,down_block_types=('DownBlock2D', 'CrossAttnDownBlock2D')	,up_block_types=('CrossAttnUpBlock2D', 'UpBlock2D')	,cross_attention_dim=32	,)
									_a     :      Tuple        =							PNDMScheduler(skip_prk_steps=_UpperCAmelCase		)
									torch.manual_seed(0		)
									_a     :      str        =							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	,)
									torch.manual_seed(0		)
									_a     :      Union[str, Any]        =							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	,)
									_a     :      str        =							CLIPTextModel(_UpperCAmelCase		)
									_a     :      Optional[int]        =							CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'		)

									_a     :      List[str]        =							{
									    'unet': unet,
									    'scheduler': scheduler,
									    'vae': vae,
									    'text_encoder': text_encoder,
									    'tokenizer': tokenizer,
									    'safety_checker': None,
									    'feature_extractor': None,
									}
									return components







							def 							__lowercase			(							self					:       Optional[Any]	,_UpperCAmelCase					:       Union[str, Any]	,_UpperCAmelCase					:       str=0		):
									_a     :      Dict        =							floats_tensor((1, 3, 32, 32)	,rng=random.Random(_UpperCAmelCase		)		).to(_UpperCAmelCase		)
									_a     :      Any        =							image.cpu().permute(0	,2	,3	,1		)[0]
									_a     :      List[Any]        =							Image.fromarray(np.uinta(_UpperCAmelCase		)		).convert('RGB'		)
									if str(_UpperCAmelCase		).startswith('mps'		):
											_a     :      Union[str, Any]        =							torch.manual_seed(_UpperCAmelCase		)
									else:
											_a     :      Union[str, Any]        =							torch.Generator(device=_UpperCAmelCase		).manual_seed(_UpperCAmelCase		)
									_a     :      List[str]        =							{
									    'prompt': 'A painting of a squirrel eating a burger',
									    'image': image,
									    'generator': generator,
									    'num_inference_steps': 2,
									    'guidance_scale': 6.0,
									    'image_guidance_scale': 1,
									    'output_type': 'numpy',
									}
									return inputs







							def 							__lowercase			(							self					:       str		):
									_a     :      Tuple        =							'cpu'  # ensure determinism for the device-dependent torch.Generator
									_a     :      int        =							self.get_dummy_components()
									_a     :      int        =							StableDiffusionInstructPixaPixPipeline(**_UpperCAmelCase		)
									_a     :      Tuple        =							sd_pipe.to(_UpperCAmelCase		)
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase		)

									_a     :      List[str]        =							self.get_dummy_inputs(_UpperCAmelCase		)
									_a     :      Dict        =							sd_pipe(**_UpperCAmelCase		).images
									_a     :      Any        =							image[0, -3:, -3:, -1]
									assert image.shape == (1, 32, 32, 3)
									_a     :      Dict        =							np.array([0.75_26, 0.37_50, 0.45_47, 0.61_17, 0.58_66, 0.50_16, 0.43_27, 0.56_42, 0.48_15]		)

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







							def 							__lowercase			(							self					:       Any		):
									_a     :      str        =							'cpu'  # ensure determinism for the device-dependent torch.Generator
									_a     :      Optional[int]        =							self.get_dummy_components()
									_a     :      Any        =							StableDiffusionInstructPixaPixPipeline(**_UpperCAmelCase		)
									_a     :      List[Any]        =							sd_pipe.to(_UpperCAmelCase		)
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase		)

									_a     :      int        =							self.get_dummy_inputs(_UpperCAmelCase		)
									_a     :      Union[str, Any]        =							'french fries'
									_a     :      Union[str, Any]        =							sd_pipe(**_UpperCAmelCase	,negative_prompt=_UpperCAmelCase		)
									_a     :      Dict        =							output.images
									_a     :      List[str]        =							image[0, -3:, -3:, -1]

									assert image.shape == (1, 32, 32, 3)
									_a     :      Dict        =							np.array([0.75_11, 0.36_42, 0.45_53, 0.62_36, 0.57_97, 0.50_13, 0.43_43, 0.56_11, 0.48_31]		)

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







							def 							__lowercase			(							self					:       Union[str, Any]		):
									_a     :      List[str]        =							'cpu'  # ensure determinism for the device-dependent torch.Generator
									_a     :      Union[str, Any]        =							self.get_dummy_components()
									_a     :      List[str]        =							StableDiffusionInstructPixaPixPipeline(**_UpperCAmelCase		)
									_a     :      str        =							sd_pipe.to(_UpperCAmelCase		)
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase		)

									_a     :      Dict        =							self.get_dummy_inputs(_UpperCAmelCase		)
									_a     :      Optional[Any]        =							[inputs['prompt']] * 2

									_a     :      Dict        =							np.array(inputs['image']		).astype(np.floataa		) / 2_55.0
									_a     :      Tuple        =							torch.from_numpy(_UpperCAmelCase		).unsqueeze(0		).to(_UpperCAmelCase		)
									_a     :      int        =							image / 2 + 0.5
									_a     :      List[Any]        =							image.permute(0	,3	,1	,2		)
									_a     :      Optional[Any]        =							image.repeat(2	,1	,1	,1		)

									_a     :      List[Any]        =							sd_pipe(**_UpperCAmelCase		).images
									_a     :      Optional[Any]        =							image[-1, -3:, -3:, -1]

									assert image.shape == (2, 32, 32, 3)
									_a     :      int        =							np.array([0.58_12, 0.57_48, 0.52_22, 0.59_08, 0.56_95, 0.71_74, 0.68_04, 0.55_23, 0.55_79]		)

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







							def 							__lowercase			(							self					:       Union[str, Any]		):
									_a     :      str        =							'cpu'  # ensure determinism for the device-dependent torch.Generator
									_a     :      Optional[Any]        =							self.get_dummy_components()
									_a     :      Optional[int]        =							EulerAncestralDiscreteScheduler(
									    beta_start=0.0_00_85	,beta_end=0.0_12	,beta_schedule='scaled_linear'		)
									_a     :      Dict        =							StableDiffusionInstructPixaPixPipeline(**_UpperCAmelCase		)
									_a     :      Any        =							sd_pipe.to(_UpperCAmelCase		)
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase		)

									_a     :      Optional[Any]        =							self.get_dummy_inputs(_UpperCAmelCase		)
									_a     :      List[str]        =							sd_pipe(**_UpperCAmelCase		).images
									_a     :      List[str]        =							image[0, -3:, -3:, -1]

									_a     :      Tuple        =							[round(_UpperCAmelCase	,4		) for x in image_slice.flatten().tolist()]
									print(','.join([str(_UpperCAmelCase		) for x in slice]		)		)

									assert image.shape == (1, 32, 32, 3)
									_a     :      Tuple        =							np.array([0.74_17, 0.38_42, 0.47_32, 0.57_76, 0.58_91, 0.51_39, 0.40_52, 0.56_73, 0.49_86]		)

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







							def 							__lowercase			(							self					:       Optional[int]		):
									super().test_inference_batch_single_identical(expected_max_diff=3E-3		)







							def 							__lowercase			(							self					:       List[Any]		):
									_a     :      int        =							self.get_dummy_components()
									_a     :      Dict        =							StableDiffusionInstructPixaPixPipeline(**_UpperCAmelCase		)
									_a     :      Optional[Any]        =							VaeImageProcessor(do_resize=_UpperCAmelCase	,do_normalize=_UpperCAmelCase		)
									_a     :      List[str]        =							pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)

									_a     :      List[Any]        =							pipe(**self.get_dummy_inputs_by_type(_UpperCAmelCase	,input_image_type='pt'		)		)[0]

									_a     :      List[Any]        =							components['vae']
									_a     :      List[Any]        =							self.get_dummy_inputs_by_type(_UpperCAmelCase	,input_image_type='pt'		)

									for image_param in self.image_latents_params:
											if image_param in inputs.keys():
													_a     :      int        =							vae.encode(inputs[image_param]		).latent_dist.mode()

									_a     :      Tuple        =							pipe(**_UpperCAmelCase		)[0]

									_a     :      Optional[Any]        =							np.abs(out - out_latents_inputs		).max()
									self.assertLess(_UpperCAmelCase	,1E-4	,'passing latents as image input generate different result from passing image'		)

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







							def 							__lowercase			(							self					:       List[str]		):
									super().tearDown()
									gc.collect()
									torch.cuda.empty_cache()







							def 							__lowercase			(							self					:       int	,_UpperCAmelCase					:       Dict=0		):
									_a     :      Union[str, Any]        =							torch.manual_seed(_UpperCAmelCase		)
									_a     :      Optional[int]        =							load_image(
									    'https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_pix2pix/example.jpg'		)
									_a     :      List[Any]        =							{
									    'prompt': 'turn him into a cyborg',
									    'image': image,
									    'generator': generator,
									    'num_inference_steps': 3,
									    'guidance_scale': 7.5,
									    'image_guidance_scale': 1.0,
									    'output_type': 'numpy',
									}
									return inputs







							def 							__lowercase			(							self					:       List[str]		):
									_a     :      Tuple        =							StableDiffusionInstructPixaPixPipeline.from_pretrained(
									    'timbrooks/instruct-pix2pix'	,safety_checker=_UpperCAmelCase		)
									pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)
									pipe.enable_attention_slicing()

									_a     :      Tuple        =							self.get_inputs()
									_a     :      List[str]        =							pipe(**_UpperCAmelCase		).images
									_a     :      List[Any]        =							image[0, -3:, -3:, -1].flatten()

									assert image.shape == (1, 512, 512, 3)
									_a     :      Tuple        =							np.array([0.59_02, 0.60_15, 0.60_27, 0.59_83, 0.60_92, 0.60_61, 0.57_65, 0.57_85, 0.55_55]		)

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







							def 							__lowercase			(							self					:       Union[str, Any]		):
									_a     :      Optional[int]        =							StableDiffusionInstructPixaPixPipeline.from_pretrained(
									    'timbrooks/instruct-pix2pix'	,safety_checker=_UpperCAmelCase		)
									_a     :      Optional[Any]        =							LMSDiscreteScheduler.from_config(pipe.scheduler.config		)
									pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)
									pipe.enable_attention_slicing()

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

									assert image.shape == (1, 512, 512, 3)
									_a     :      Optional[Any]        =							np.array([0.65_78, 0.68_17, 0.69_72, 0.67_61, 0.68_56, 0.69_16, 0.64_28, 0.65_16, 0.63_01]		)

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







							def 							__lowercase			(							self					:       List[Any]		):
									_a     :      Any        =							StableDiffusionInstructPixaPixPipeline.from_pretrained(
									    'timbrooks/instruct-pix2pix'	,safety_checker=_UpperCAmelCase		)
									_a     :      List[Any]        =							DDIMScheduler.from_config(pipe.scheduler.config		)
									pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)
									pipe.enable_attention_slicing()

									_a     :      List[Any]        =							self.get_inputs()
									_a     :      str        =							pipe(**_UpperCAmelCase		).images
									_a     :      List[Any]        =							image[0, -3:, -3:, -1].flatten()

									assert image.shape == (1, 512, 512, 3)
									_a     :      Optional[Any]        =							np.array([0.38_28, 0.38_34, 0.38_18, 0.37_92, 0.38_65, 0.37_52, 0.37_92, 0.38_47, 0.37_53]		)

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







							def 							__lowercase			(							self					:       Optional[int]		):
									_a     :      List[Any]        =							0

									def callback_fn(_UpperCAmelCase					:       int	,_UpperCAmelCase					:       int	,_UpperCAmelCase					:       torch.FloatTensor		) -> None:
											_a     :      Dict        =							True
											nonlocal number_of_steps
											number_of_steps += 1
											if step == 1:
													_a     :      str        =							latents.detach().cpu().numpy()
													assert latents.shape == (1, 4, 64, 64)
													_a     :      List[Any]        =							latents[0, -3:, -3:, -1]
													_a     :      Union[str, Any]        =							np.array([-0.24_63, -0.46_44, -0.97_56, 1.51_76, 1.44_14, 0.78_66, 0.98_97, 0.85_21, 0.79_83]		)

													assert np.abs(latents_slice.flatten() - expected_slice		).max() < 5E-2
											elif step == 2:
													_a     :      Optional[int]        =							latents.detach().cpu().numpy()
													assert latents.shape == (1, 4, 64, 64)
													_a     :      Tuple        =							latents[0, -3:, -3:, -1]
													_a     :      Tuple        =							np.array([-0.26_44, -0.46_26, -0.96_53, 1.51_76, 1.45_51, 0.76_86, 0.98_05, 0.84_52, 0.81_15]		)

													assert np.abs(latents_slice.flatten() - expected_slice		).max() < 5E-2

									_a     :      int        =							False

									_a     :      List[str]        =							StableDiffusionInstructPixaPixPipeline.from_pretrained(
									    'timbrooks/instruct-pix2pix'	,safety_checker=_UpperCAmelCase	,torch_dtype=torch.floataa		)
									_a     :      Any        =							pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)
									pipe.enable_attention_slicing()

									_a     :      Optional[int]        =							self.get_inputs()
									pipe(**_UpperCAmelCase	,callback=_UpperCAmelCase	,callback_steps=1		)
									assert callback_fn.has_been_called
									assert number_of_steps == 3







							def 							__lowercase			(							self					:       List[str]		):
									torch.cuda.empty_cache()
									torch.cuda.reset_max_memory_allocated()
									torch.cuda.reset_peak_memory_stats()

									_a     :      Tuple        =							StableDiffusionInstructPixaPixPipeline.from_pretrained(
									    'timbrooks/instruct-pix2pix'	,safety_checker=_UpperCAmelCase	,torch_dtype=torch.floataa		)
									_a     :      Tuple        =							pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)
									pipe.enable_attention_slicing(1		)
									pipe.enable_sequential_cpu_offload()

									_a     :      Any        =							self.get_inputs()
									_a     :      Dict        =							pipe(**_UpperCAmelCase		)

									_a     :      Optional[Any]        =							torch.cuda.max_memory_allocated()
									# make sure that less than 2.2 GB is allocated
									assert mem_bytes < 2.2 * 10**9







							def 							__lowercase			(							self					:       str		):
									_a     :      Any        =							self.get_inputs()
									# resize to resolution that is divisible by 8 but not 16 or 32
									_a     :      Any        =							inputs['image'].resize((504, 504)		)

									_a     :      int        =							'timbrooks/instruct-pix2pix'
									_a     :      Any        =							StableDiffusionInstructPixaPixPipeline.from_pretrained(
									    _UpperCAmelCase	,safety_checker=_UpperCAmelCase	,)
									pipe.to(_UpperCAmelCase		)
									pipe.set_progress_bar_config(disable=_UpperCAmelCase		)
									pipe.enable_attention_slicing()

									_a     :      Optional[int]        =							pipe(**_UpperCAmelCase		)
									_a     :      Any        =							output.images[0]

									_a     :      Any        =							image[255:258, 383:386, -1]

									assert image.shape == (504, 504, 3)
									_a     :      int        =							np.array([0.27_26, 0.25_29, 0.26_64, 0.26_55, 0.26_41, 0.26_42, 0.25_91, 0.26_49, 0.25_90]		)

									assert np.abs(image_slice.flatten() - expected_slice		).max() < 5E-3









'''simple docstring'''

import multiprocessing
from typing import TYPE_CHECKING, Optional, Union

from .. import Dataset, Features, config
from ..formatting import query_table
from ..packaged_modules.sql.sql import Sql
from ..utils import logging
from .abc import AbstractDatasetInputStream


if TYPE_CHECKING:
							import sqlitea

							import sqlalchemy

class 	__magic_name__						(    _UpperCamelCase   ):







							def __init__(							self					:       Optional[int]	,_UpperCAmelCase					:       Union[str, "sqlalchemy.sql.Selectable"]	,_UpperCAmelCase					:       Union[str, "sqlalchemy.engine.Connection", "sqlalchemy.engine.Engine", "sqlite3.Connection"]	,_UpperCAmelCase					:       Optional[Features] = None	,_UpperCAmelCase					:       str = None	,_UpperCAmelCase					:       bool = False	,**_UpperCAmelCase					:       Dict	,):
									super().__init__(features=_UpperCAmelCase	,cache_dir=_UpperCAmelCase	,keep_in_memory=_UpperCAmelCase	,**_UpperCAmelCase		)
									_a     :      Tuple        =							Sql(
									    cache_dir=_UpperCAmelCase	,features=_UpperCAmelCase	,sql=_UpperCAmelCase	,con=_UpperCAmelCase	,**_UpperCAmelCase	,)







							def 							__lowercase			(							self					:       Dict		):
									_a     :      Optional[Any]        =							None
									_a     :      Dict        =							None
									_a     :      Dict        =							None
									_a     :      Optional[int]        =							None

									self.builder.download_and_prepare(
									    download_config=_UpperCAmelCase	,download_mode=_UpperCAmelCase	,verification_mode=_UpperCAmelCase	,base_path=_UpperCAmelCase	,)

									# Build dataset for splits
									_a     :      List[str]        =							self.builder.as_dataset(
									    split='train'	,verification_mode=_UpperCAmelCase	,in_memory=self.keep_in_memory		)
									return dataset

class 	__magic_name__						:







							def __init__(							self					:       Optional[int]	,_UpperCAmelCase					:       Dataset	,_UpperCAmelCase					:       str	,_UpperCAmelCase					:       Union[str, "sqlalchemy.engine.Connection", "sqlalchemy.engine.Engine", "sqlite3.Connection"]	,_UpperCAmelCase					:       Optional[int] = None	,_UpperCAmelCase					:       Optional[int] = None	,**_UpperCAmelCase					:       Dict	,):
									if num_proc is not None and num_proc <= 0:
											raise ValueError(F"""num_proc {num_proc} must be an integer > 0."""		)

									_a     :      Dict        =							dataset
									_a     :      List[Any]        =							name
									_a     :      Tuple        =							con
									_a     :      Union[str, Any]        =							batch_size if batch_size else config.DEFAULT_MAX_BATCH_SIZE
									_a     :      List[Any]        =							num_proc
									_a     :      Tuple        =							to_sql_kwargs







							def 							__lowercase			(							self					:       List[Any]		):
									_a     :      Tuple        =							self.to_sql_kwargs.pop('sql'	,_UpperCAmelCase		)
									_a     :      str        =							self.to_sql_kwargs.pop('con'	,_UpperCAmelCase		)
									_a     :      Optional[Any]        =							self.to_sql_kwargs.pop('index'	,_UpperCAmelCase		)

									_a     :      Any        =							self._write(index=_UpperCAmelCase	,**self.to_sql_kwargs		)
									return written







							def 							__lowercase			(							self					:       Optional[int]	,_UpperCAmelCase					:       Dict		):
									_a       ,					_a       ,					_a     :      Any        =							args
									_a     :      Tuple        =							{**to_sql_kwargs, 'if_exists': 'append'} if offset > 0 else to_sql_kwargs
									_a     :      Dict        =							query_table(
									    table=self.dataset.data	,key=slice(_UpperCAmelCase	,offset + self.batch_size		)	,indices=self.dataset._indices	,)
									_a     :      Tuple        =							batch.to_pandas()
									_a     :      Dict        =							df.to_sql(self.name	,self.con	,index=_UpperCAmelCase	,**_UpperCAmelCase		)
									return num_rows or len(_UpperCAmelCase		)







							def 							__lowercase			(							self					:       int	,_UpperCAmelCase					:       Optional[int]	,**_UpperCAmelCase					:       List[Any]		):
									_a     :      Union[str, Any]        =							0

									if self.num_proc is None or self.num_proc == 1:
											for offset in logging.tqdm(
											    range(0	,len(self.dataset		)	,self.batch_size		)	,unit='ba'	,disable=not logging.is_progress_bar_enabled()	,desc='Creating SQL from Arrow format'	,):
													written += self._batch_sql((offset, index, to_sql_kwargs)		)
									else:
											_a       ,					_a     :      List[Any]        =							len(self.dataset		), self.batch_size
											with multiprocessing.Pool(self.num_proc		) as pool:
													for num_rows in logging.tqdm(
													    pool.imap(
													        self._batch_sql	,[(offset, index, to_sql_kwargs) for offset in range(0	,_UpperCAmelCase	,_UpperCAmelCase		)]	,)	,total=(num_rows // batch_size) + 1 if num_rows % batch_size else num_rows // batch_size	,unit='ba'	,disable=not logging.is_progress_bar_enabled()	,desc='Creating SQL from Arrow format'	,):
															written += num_rows

									return written




