
import inspect
import unittest

from transformers import YolosConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch
							from torch import nn

							from transformers import YolosForObjectDetection, YolosModel
							from transformers.models.yolos.modeling_yolos import YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
							from PIL import Image

							from transformers import AutoImageProcessor





class     lowercase							:
					def __init__(		self			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__=13			,						SCREAMING_SNAKE_CASE__=[30, 30]			,						SCREAMING_SNAKE_CASE__=2			,						SCREAMING_SNAKE_CASE__=3			,						SCREAMING_SNAKE_CASE__=True			,						SCREAMING_SNAKE_CASE__=True			,						SCREAMING_SNAKE_CASE__=32			,						SCREAMING_SNAKE_CASE__=5			,						SCREAMING_SNAKE_CASE__=4			,						SCREAMING_SNAKE_CASE__=37			,						SCREAMING_SNAKE_CASE__="gelu"			,						SCREAMING_SNAKE_CASE__=0.1			,						SCREAMING_SNAKE_CASE__=0.1			,						SCREAMING_SNAKE_CASE__=10			,						SCREAMING_SNAKE_CASE__=0.02			,						SCREAMING_SNAKE_CASE__=3			,						SCREAMING_SNAKE_CASE__=None			,						SCREAMING_SNAKE_CASE__=8			,						SCREAMING_SNAKE_CASE__=10			,						):
								"""simple docstring"""







								lowerCAmelCase__			:     Dict					   =      parent
								lowerCAmelCase__			:     Any					   =      batch_size
								lowerCAmelCase__			:     List[Any]					   =      image_size
								lowerCAmelCase__			:     Optional[Any]					   =      patch_size
								lowerCAmelCase__			:     Tuple					   =      num_channels
								lowerCAmelCase__			:     int					   =      is_training
								lowerCAmelCase__			:     Dict					   =      use_labels
								lowerCAmelCase__			:     Optional[Any]					   =      hidden_size
								lowerCAmelCase__			:     int					   =      num_hidden_layers
								lowerCAmelCase__			:     Tuple					   =      num_attention_heads
								lowerCAmelCase__			:     List[Any]					   =      intermediate_size
								lowerCAmelCase__			:     List[Any]					   =      hidden_act
								lowerCAmelCase__			:     Optional[Any]					   =      hidden_dropout_prob
								lowerCAmelCase__			:     Union[str, Any]					   =      attention_probs_dropout_prob
								lowerCAmelCase__			:     Dict					   =      type_sequence_label_size
								lowerCAmelCase__			:     str					   =      initializer_range
								lowerCAmelCase__			:     Optional[int]					   =      num_labels
								lowerCAmelCase__			:     str					   =      scope
								lowerCAmelCase__			:     int					   =      n_targets
								lowerCAmelCase__			:     str					   =      num_detection_tokens
								# we set the expected sequence length (which is used in several tests)
								# expected sequence length = num_patches + 1 (we add 1 for the [CLS] token) + num_detection_tokens
								lowerCAmelCase__			:     str					   =      (image_size[1] // patch_size) * (image_size[0] // patch_size)
								lowerCAmelCase__			:     Dict					   =      num_patches + 1 + self.num_detection_tokens
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Optional[Any]					   =      floats_tensor([self.batch_size, self.num_channels, self.image_size[0], self.image_size[1]]     )

								lowerCAmelCase__			:     List[Any]					   =      None
								if self.use_labels:
											# labels is a list of Dict (each Dict being the labels for a given example in the batch)
											lowerCAmelCase__			:     Union[str, Any]					   =      []
											for i in range(self.batch_size     ):
														lowerCAmelCase__			:     Tuple					   =      {}
														lowerCAmelCase__			:     Tuple					   =      torch.randint(
														    high=self.num_labels			,						size=(self.n_targets,)			,						device=__lowerCAmelCase     )
														lowerCAmelCase__			:     Union[str, Any]					   =      torch.rand(self.n_targets			,						4			,						device=__lowerCAmelCase     )
														labels.append(__lowerCAmelCase     )

								lowerCAmelCase__			:     int					   =      self.get_config()

								return config, pixel_values, labels
					def lowercase_      (		self     ):
								"""simple docstring"""







								return YolosConfig(
								    image_size=self.image_size			,						patch_size=self.patch_size			,						num_channels=self.num_channels			,						hidden_size=self.hidden_size			,						num_hidden_layers=self.num_hidden_layers			,						num_attention_heads=self.num_attention_heads			,						intermediate_size=self.intermediate_size			,						hidden_act=self.hidden_act			,						hidden_dropout_prob=self.hidden_dropout_prob			,						attention_probs_dropout_prob=self.attention_probs_dropout_prob			,						is_decoder=__lowerCAmelCase			,						initializer_range=self.initializer_range			,						num_detection_tokens=self.num_detection_tokens			,						num_labels=self.num_labels			,						)
					def lowercase_      (		self			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Union[str, Any]					   =      YolosModel(config=__lowerCAmelCase     )
								model.to(__lowerCAmelCase     )
								model.eval()
								lowerCAmelCase__			:     int					   =      model(__lowerCAmelCase     )
								self.parent.assertEqual(
								    result.last_hidden_state.shape			,						(self.batch_size, self.expected_seq_len, self.hidden_size)     )
					def lowercase_      (		self			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__     ):
								"""simple docstring"""







								lowerCAmelCase__			:     List[Any]					   =      YolosForObjectDetection(__lowerCAmelCase     )
								model.to(__lowerCAmelCase     )
								model.eval()

								lowerCAmelCase__			:     Dict					   =      model(pixel_values=__lowerCAmelCase     )
								lowerCAmelCase__			:     List[Any]					   =      model(__lowerCAmelCase     )

								self.parent.assertEqual(result.logits.shape			,						(self.batch_size, self.num_detection_tokens, self.num_labels + 1)     )
								self.parent.assertEqual(result.pred_boxes.shape			,						(self.batch_size, self.num_detection_tokens, 4)     )

								lowerCAmelCase__			:     Tuple					   =      model(pixel_values=__lowerCAmelCase			,						labels=__lowerCAmelCase     )

								self.parent.assertEqual(result.loss.shape			,						()     )
								self.parent.assertEqual(result.logits.shape			,						(self.batch_size, self.num_detection_tokens, self.num_labels + 1)     )
								self.parent.assertEqual(result.pred_boxes.shape			,						(self.batch_size, self.num_detection_tokens, 4)     )
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Optional[int]					   =      self.prepare_config_and_inputs()
								lowerCAmelCase__   ,					lowerCAmelCase__   ,					lowerCAmelCase__			:     Optional[Any]					   =      config_and_inputs
								lowerCAmelCase__			:     List[Any]					   =      {'''pixel_values''': pixel_values}
								return config, inputs_dict





@require_torch
class     lowercase							(	__UpperCamelCase						,		__UpperCamelCase						,		unittest.TestCase       ):
					__a											=     (YolosModel, YolosForObjectDetection) if is_torch_available() else ()
					__a											=     (
					    {'''feature-extraction''': YolosModel, '''object-detection''': YolosForObjectDetection} if is_torch_available() else {}
					)

					__a											=     False
					__a											=     False
					__a											=     False
					__a											=     False
					def lowercase_      (		self			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__=False     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Optional[Any]					   =      super()._prepare_for_class(__lowerCAmelCase			,						__lowerCAmelCase			,						return_labels=__lowerCAmelCase     )

								if return_labels:
											if model_class.__name__ == "YolosForObjectDetection":
														lowerCAmelCase__			:     List[str]					   =      []
														for i in range(self.model_tester.batch_size     ):
																	lowerCAmelCase__			:     Optional[Any]					   =      {}
																	lowerCAmelCase__			:     Dict					   =      torch.ones(
																	    size=(self.model_tester.n_targets,)			,						device=__lowerCAmelCase			,						dtype=torch.long     )
																	lowerCAmelCase__			:     int					   =      torch.ones(
																	    self.model_tester.n_targets			,						4			,						device=__lowerCAmelCase			,						dtype=torch.float     )
																	labels.append(__lowerCAmelCase     )
														lowerCAmelCase__			:     List[Any]					   =      labels

								return inputs_dict
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Optional[Any]					   =      YolosModelTester(self     )
								lowerCAmelCase__			:     Any					   =      ConfigTester(self			,						config_class=__lowerCAmelCase			,						has_text_modality=__lowerCAmelCase			,						hidden_size=37     )
					def lowercase_      (		self     ):
								"""simple docstring"""







								self.config_tester.run_common_tests()
					def lowercase_      (		self     ):
								"""simple docstring"""







								pass
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__   ,					lowerCAmelCase__			:     Tuple					   =      self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
											lowerCAmelCase__			:     Optional[Any]					   =      model_class(__lowerCAmelCase     )
											self.assertIsInstance(model.get_input_embeddings()			,						(nn.Module)     )
											lowerCAmelCase__			:     Union[str, Any]					   =      model.get_output_embeddings()
											self.assertTrue(x is None or isinstance(__lowerCAmelCase			,						nn.Linear     )     )
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__   ,					lowerCAmelCase__			:     List[str]					   =      self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
											lowerCAmelCase__			:     Tuple					   =      model_class(__lowerCAmelCase     )
											lowerCAmelCase__			:     List[str]					   =      inspect.signature(model.forward     )
											# signature.parameters is an OrderedDict => so arg_names order is deterministic
											lowerCAmelCase__			:     List[str]					   =      [*signature.parameters.keys()]

											lowerCAmelCase__			:     List[str]					   =      ['''pixel_values''']
											self.assertListEqual(arg_names[:1]			,						__lowerCAmelCase     )
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__			:     List[Any]					   =      self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*__lowerCAmelCase     )
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__   ,					lowerCAmelCase__			:     List[Any]					   =      self.model_tester.prepare_config_and_inputs_for_common()
								lowerCAmelCase__			:     Dict					   =      True

								# in YOLOS, the seq_len is different
								lowerCAmelCase__			:     Any					   =      self.model_tester.expected_seq_len
								for model_class in self.all_model_classes:
											lowerCAmelCase__			:     List[str]					   =      True
											lowerCAmelCase__			:     int					   =      False
											lowerCAmelCase__			:     str					   =      True
											lowerCAmelCase__			:     List[Any]					   =      model_class(__lowerCAmelCase     )
											model.to(__lowerCAmelCase     )
											model.eval()
											with torch.no_grad():
														lowerCAmelCase__			:     Dict					   =      model(**self._prepare_for_class(__lowerCAmelCase			,						__lowerCAmelCase     )     )
											lowerCAmelCase__			:     Optional[int]					   =      outputs.attentions
											self.assertEqual(len(__lowerCAmelCase     )			,						self.model_tester.num_hidden_layers     )

											# check that output_attentions also work using config
											del inputs_dict["output_attentions"]
											lowerCAmelCase__			:     Union[str, Any]					   =      True
											lowerCAmelCase__			:     Optional[int]					   =      model_class(__lowerCAmelCase     )
											model.to(__lowerCAmelCase     )
											model.eval()
											with torch.no_grad():
														lowerCAmelCase__			:     Union[str, Any]					   =      model(**self._prepare_for_class(__lowerCAmelCase			,						__lowerCAmelCase     )     )
											lowerCAmelCase__			:     Optional[int]					   =      outputs.attentions
											self.assertEqual(len(__lowerCAmelCase     )			,						self.model_tester.num_hidden_layers     )

											self.assertListEqual(
											    list(attentions[0].shape[-3:]     )			,						[self.model_tester.num_attention_heads, seq_len, seq_len]			,						)
											lowerCAmelCase__			:     Dict					   =      len(__lowerCAmelCase     )

											# Check attention is always last and order is fine
											lowerCAmelCase__			:     List[Any]					   =      True
											lowerCAmelCase__			:     str					   =      True
											lowerCAmelCase__			:     Optional[int]					   =      model_class(__lowerCAmelCase     )
											model.to(__lowerCAmelCase     )
											model.eval()
											with torch.no_grad():
														lowerCAmelCase__			:     Optional[Any]					   =      model(**self._prepare_for_class(__lowerCAmelCase			,						__lowerCAmelCase     )     )

											lowerCAmelCase__			:     int					   =      1
											self.assertEqual(out_len + added_hidden_states			,						len(__lowerCAmelCase     )     )

											lowerCAmelCase__			:     Optional[int]					   =      outputs.attentions

											self.assertEqual(len(__lowerCAmelCase     )			,						self.model_tester.num_hidden_layers     )
											self.assertListEqual(
											    list(self_attentions[0].shape[-3:]     )			,						[self.model_tester.num_attention_heads, seq_len, seq_len]			,						)
					def lowercase_      (		self     ):
								"""simple docstring"""







								def check_hidden_states_output(SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__     ):
											lowerCAmelCase__			:     Optional[int]					   =      model_class(__lowerCAmelCase     )
											model.to(__lowerCAmelCase     )
											model.eval()

											with torch.no_grad():
														lowerCAmelCase__			:     int					   =      model(**self._prepare_for_class(__lowerCAmelCase			,						__lowerCAmelCase     )     )

											lowerCAmelCase__			:     Optional[Any]					   =      outputs.hidden_states

											lowerCAmelCase__			:     Optional[int]					   =      getattr(
											    self.model_tester			,						'''expected_num_hidden_layers'''			,						self.model_tester.num_hidden_layers + 1     )
											self.assertEqual(len(__lowerCAmelCase     )			,						__lowerCAmelCase     )

											# YOLOS has a different seq_length
											lowerCAmelCase__			:     Union[str, Any]					   =      self.model_tester.expected_seq_len

											self.assertListEqual(
											    list(hidden_states[0].shape[-2:]     )			,						[seq_length, self.model_tester.hidden_size]			,						)

								lowerCAmelCase__   ,					lowerCAmelCase__			:     List[Any]					   =      self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
											lowerCAmelCase__			:     List[Any]					   =      True
											check_hidden_states_output(__lowerCAmelCase			,						__lowerCAmelCase			,						__lowerCAmelCase     )

											# check that output_hidden_states also work using config
											del inputs_dict["output_hidden_states"]
											lowerCAmelCase__			:     str					   =      True

											check_hidden_states_output(__lowerCAmelCase			,						__lowerCAmelCase			,						__lowerCAmelCase     )
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Optional[int]					   =      self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_object_detection(*__lowerCAmelCase     )
					@slow
					def lowercase_      (		self     ):
								"""simple docstring"""







								for model_name in YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											lowerCAmelCase__			:     Optional[Any]					   =      YolosModel.from_pretrained(__lowerCAmelCase     )
											self.assertIsNotNone(__lowerCAmelCase     )





def   _a  ( ):
			lowerCAmelCase__			:     List[Any]					   =      Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''     )
			return image





@require_torch
@require_vision
class     lowercase							(	unittest.TestCase       ):
					@cached_property
					def lowercase_      (		self     ):
								"""simple docstring"""







								return AutoImageProcessor.from_pretrained('''hustvl/yolos-small'''     ) if is_vision_available() else None
					@slow
					def lowercase_      (		self     ):
								"""simple docstring"""







								lowerCAmelCase__			:     Dict					   =      YolosForObjectDetection.from_pretrained('''hustvl/yolos-small'''     ).to(__lowerCAmelCase     )

								lowerCAmelCase__			:     Optional[int]					   =      self.default_image_processor
								lowerCAmelCase__			:     Optional[Any]					   =      prepare_img()
								lowerCAmelCase__			:     List[str]					   =      image_processor(images=__lowerCAmelCase			,						return_tensors='''pt'''     ).to(__lowerCAmelCase     )

								# forward pass
								with torch.no_grad():
											lowerCAmelCase__			:     Optional[int]					   =      model(inputs.pixel_values     )

								# verify outputs
								lowerCAmelCase__			:     Optional[int]					   =      torch.Size((1, 100, 92)     )
								self.assertEqual(outputs.logits.shape			,						__lowerCAmelCase     )

								lowerCAmelCase__			:     Dict					   =      torch.tensor(
								    [[-24.0248, -10.3024, -14.8290], [-42.0392, -16.8200, -27.4334], [-27.2743, -11.8154, -18.7148]]			,						device=__lowerCAmelCase			,						)
								lowerCAmelCase__			:     Any					   =      torch.tensor(
								    [[0.2_559, 0.5_455, 0.4_706], [0.2_989, 0.7_279, 0.1_875], [0.7_732, 0.4_017, 0.4_462]]			,						device=__lowerCAmelCase     )
								self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]			,						__lowerCAmelCase			,						atol=1E-4     )     )
								self.assertTrue(torch.allclose(outputs.pred_boxes[0, :3, :3]			,						__lowerCAmelCase			,						atol=1E-4     )     )

								# verify postprocessing
								lowerCAmelCase__			:     int					   =      image_processor.post_process_object_detection(
								    __lowerCAmelCase			,						threshold=0.3			,						target_sizes=[image.size[::-1]]     )[0]
								lowerCAmelCase__			:     Tuple					   =      torch.tensor([0.9_994, 0.9_790, 0.9_964, 0.9_972, 0.9_861]     ).to(__lowerCAmelCase     )
								lowerCAmelCase__			:     int					   =      [75, 75, 17, 63, 17]
								lowerCAmelCase__			:     str					   =      torch.tensor([335.0609, 79.3848, 375.4216, 187.2495]     ).to(__lowerCAmelCase     )

								self.assertEqual(len(results['''scores''']     )			,						5     )
								self.assertTrue(torch.allclose(results['''scores''']			,						__lowerCAmelCase			,						atol=1E-4     )     )
								self.assertSequenceEqual(results['''labels'''].tolist()			,						__lowerCAmelCase     )
								self.assertTrue(torch.allclose(results['''boxes'''][0, :]			,						__lowerCAmelCase     )     )










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     A     (SCREAMING_SNAKE_CASE       ):
			'''simple docstring'''




			def __init__(     self  :       Any				,      __lowerCAmelCase  :       Union[str, "sqlalchemy.sql.Selectable"]				,      __lowerCAmelCase  :       Union[str, "sqlalchemy.engine.Connection", "sqlalchemy.engine.Engine", "sqlite3.Connection"]				,      __lowerCAmelCase  :       Optional[Features] = None				,      __lowerCAmelCase  :       str = None				,      __lowerCAmelCase  :       bool = False				,      **__lowerCAmelCase  :       Dict				,      )      ->      Any:







					"""simple docstring"""






					super().__init__(features=__lowerCAmelCase				,      cache_dir=__lowerCAmelCase				,      keep_in_memory=__lowerCAmelCase				,      **__lowerCAmelCase  )
					A__     =  Sql(
					    cache_dir=__lowerCAmelCase				,      features=__lowerCAmelCase				,      sql=__lowerCAmelCase				,      con=__lowerCAmelCase				,      **__lowerCAmelCase				,      )







			def   a_			(     self  :       Optional[int]  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  None
					A__     =  None
					A__     =  None
					A__     =  None

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

					# Build dataset for splits
					A__     =  self.builder.as_dataset(
					    split="""train"""				,      verification_mode=__lowerCAmelCase				,      in_memory=self.keep_in_memory  )
					return dataset


class     A     :
			'''simple docstring'''




			def __init__(     self  :       Optional[int]				,      __lowerCAmelCase  :       Dataset				,      __lowerCAmelCase  :       str				,      __lowerCAmelCase  :       Union[str, "sqlalchemy.engine.Connection", "sqlalchemy.engine.Engine", "sqlite3.Connection"]				,      __lowerCAmelCase  :       Optional[int] = None				,      __lowerCAmelCase  :       Optional[int] = None				,      **__lowerCAmelCase  :       List[Any]				,      )      ->      Any:







					"""simple docstring"""






					if num_proc is not None and num_proc <= 0:
							raise ValueError(f'num_proc {num_proc} must be an integer > 0.'  )

					A__     =  dataset
					A__     =  name
					A__     =  con
					A__     =  batch_size if batch_size else config.DEFAULT_MAX_BATCH_SIZE
					A__     =  num_proc
					A__     =  to_sql_kwargs






			def   a_			(     self  :       Any  )      ->      int:







					"""simple docstring"""






					A__     =  self.to_sql_kwargs.pop("""sql"""				,      __lowerCAmelCase  )
					A__     =  self.to_sql_kwargs.pop("""con"""				,      __lowerCAmelCase  )
					A__     =  self.to_sql_kwargs.pop("""index"""				,      __lowerCAmelCase  )

					A__     =  self._write(index=__lowerCAmelCase				,      **self.to_sql_kwargs  )
					return written






			def   a_			(     self  :       Union[str, Any]				,      __lowerCAmelCase  :       Optional[Any]  )      ->      Optional[Any]:







					"""simple docstring"""






					A__ ,     A__ ,     A__     =  args
					A__     =  {**to_sql_kwargs, """if_exists""": """append"""} if offset > 0 else to_sql_kwargs
					A__     =  query_table(
					    table=self.dataset.data				,      key=slice(__lowerCAmelCase				,      offset + self.batch_size  )				,      indices=self.dataset._indices				,      )
					A__     =  batch.to_pandas()
					A__     =  df.to_sql(self.name				,      self.con				,      index=__lowerCAmelCase				,      **__lowerCAmelCase  )
					return num_rows or len(__lowerCAmelCase  )







			def   a_			(     self  :       Optional[int]				,      __lowerCAmelCase  :       Tuple				,      **__lowerCAmelCase  :       Dict  )      ->      int:







					"""simple docstring"""






					A__     =  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__     =  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				,      __lowerCAmelCase				,      __lowerCAmelCase  )]				,      )				,      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



