import unittest

from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available
from transformers.pipelines import pipeline
from transformers.pipelines.document_question_answering import apply_tesseract
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_detectrona,
    require_pytesseract,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
      from PIL import Image

      from transformers.image_utils import load_image
else:






      class 		_lowerCamelCase		:
          @staticmethod
          def     UpperCamelCase_					(	*lowerCAmelCase			,			**lowerCAmelCase )							->       Optional[int]:
           pass







      def       A__   (						snake_case_			:		Optional[int]   ):
       return None


# This is a pinned image from a specific revision of a document question answering space, hosted by HuggingFace,
# so we can expect it to be available.
lowercase_  : int								=					(
    "https://huggingface.co/spaces/impira/docquery/resolve/2f6c96314dc84dfda62d40de9da55f2f5165d403/invoice.png"
)






@is_pipeline_test
@require_torch
@require_vision
class 		_lowerCamelCase		( unittest.TestCase     ):
    __a						=   MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING
    @require_pytesseract
    @require_vision
    def     UpperCamelCase_					(	self			,			lowerCAmelCase			,			lowerCAmelCase			,			lowerCAmelCase )							->       Any:
     SCREAMING_SNAKE_CASE__: int=   pipeline(
         '''document-question-answering'''			,			model=a_			,			tokenizer=a_			,			image_processor=a_ )

     SCREAMING_SNAKE_CASE__: Tuple=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: List[str]=   list(zip(*apply_tesseract(load_image(a_ )			,			a_			,			'''''' ) ) )
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   '''What is the placebo?'''
     SCREAMING_SNAKE_CASE__: List[str]=   [
         {
             '''image''': load_image(a_ ),
             '''question''': question,
         },
         {
             '''image''': image,
             '''question''': question,
         },
         {
             '''image''': image,
             '''question''': question,
             '''word_boxes''': word_boxes,
         },
     ]
     return dqa_pipeline, examples
    def     UpperCamelCase_					(	self			,			lowerCAmelCase			,			lowerCAmelCase )							->       List[Any]:
     SCREAMING_SNAKE_CASE__: int=   dqa_pipeline(a_			,			top_k=2 )
     self.assertEqual(
         a_			,			[
             [
                 {'''score''': ANY(a_ ), '''answer''': ANY(a_ ), '''start''': ANY(a_ ), '''end''': ANY(a_ )},
                 {'''score''': ANY(a_ ), '''answer''': ANY(a_ ), '''start''': ANY(a_ ), '''end''': ANY(a_ )},
             ]
         ]
         * 3			,			)
    @require_torch
    @require_detectrona
    @require_pytesseract
    def     UpperCamelCase_					(	self )							->       List[Any]:
     SCREAMING_SNAKE_CASE__: Optional[int]=   pipeline('''document-question-answering'''			,			model='''hf-internal-testing/tiny-random-layoutlmv2''' )
     SCREAMING_SNAKE_CASE__: Dict=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: Tuple=   '''How many cats are there?'''

     SCREAMING_SNAKE_CASE__: List[Any]=   [
         {'''score''': 0.0001, '''answer''': '''oy 2312/2019''', '''start''': 38, '''end''': 39},
         {'''score''': 0.0001, '''answer''': '''oy 2312/2019 DUE''', '''start''': 38, '''end''': 40},
     ]
     SCREAMING_SNAKE_CASE__: int=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(nested_simplify(a_			,			decimals=4 )			,			a_ )

     SCREAMING_SNAKE_CASE__: Optional[int]=   dqa_pipeline({'''image''': image, '''question''': question}			,			top_k=2 )
     self.assertEqual(nested_simplify(a_			,			decimals=4 )			,			a_ )

     # This image does not detect ANY text in it, meaning layoutlmv2 should fail.
     # Empty answer probably
     SCREAMING_SNAKE_CASE__: Dict=   '''./tests/fixtures/tests_samples/COCO/000000039769.png'''
     SCREAMING_SNAKE_CASE__: List[Any]=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(a_			,			[] )

     # We can optionnally pass directly the words and bounding boxes
     SCREAMING_SNAKE_CASE__: List[str]=   '''./tests/fixtures/tests_samples/COCO/000000039769.png'''
     SCREAMING_SNAKE_CASE__: int=   []
     SCREAMING_SNAKE_CASE__: Dict=   []
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   dqa_pipeline(image=a_			,			question=a_			,			words=a_			,			boxes=a_			,			top_k=2 )
     self.assertEqual(a_			,			[] )
    @slow
    @require_torch
    @require_detectrona
    @require_pytesseract
    def     UpperCamelCase_					(	self )							->       Optional[int]:
     SCREAMING_SNAKE_CASE__: Optional[Any]=   pipeline(
         '''document-question-answering'''			,			model='''tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa'''			,			revision='''9977165'''			,			)
     SCREAMING_SNAKE_CASE__: str=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: Dict=   '''What is the invoice number?'''

     SCREAMING_SNAKE_CASE__: Optional[Any]=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.9944, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.0009, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
         ]			,			)

     SCREAMING_SNAKE_CASE__: List[str]=   dqa_pipeline({'''image''': image, '''question''': question}			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.9944, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.0009, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
         ]			,			)

     SCREAMING_SNAKE_CASE__: Optional[int]=   dqa_pipeline(
         [{'''image''': image, '''question''': question}, {'''image''': image, '''question''': question}]			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             [
                 {'''score''': 0.9944, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
                 {'''score''': 0.0009, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             ],
         ]
         * 2			,			)
    @slow
    @require_torch
    @require_detectrona
    @require_pytesseract
    def     UpperCamelCase_					(	self )							->       List[str]:
     SCREAMING_SNAKE_CASE__: int=   pipeline(
         '''document-question-answering'''			,			model='''tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa'''			,			revision='''9977165'''			,			max_seq_len=50			,			)
     SCREAMING_SNAKE_CASE__: str=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   '''What is the invoice number?'''

     SCREAMING_SNAKE_CASE__: List[Any]=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.9974, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
             {'''score''': 0.9948, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
         ]			,			)

     SCREAMING_SNAKE_CASE__: Tuple=   dqa_pipeline({'''image''': image, '''question''': question}			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.9974, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
             {'''score''': 0.9948, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
         ]			,			)

     SCREAMING_SNAKE_CASE__: List[str]=   dqa_pipeline(
         [{'''image''': image, '''question''': question}, {'''image''': image, '''question''': question}]			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             [
                 {'''score''': 0.9974, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
                 {'''score''': 0.9948, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             ]
         ]
         * 2			,			)
    @slow
    @require_torch
    @require_pytesseract
    @require_vision
    def     UpperCamelCase_					(	self )							->       Optional[int]:
     SCREAMING_SNAKE_CASE__: Tuple=   AutoTokenizer.from_pretrained(
         '''impira/layoutlm-document-qa'''			,			revision='''3dc6de3'''			,			add_prefix_space=a_ )
     SCREAMING_SNAKE_CASE__: List[str]=   pipeline(
         '''document-question-answering'''			,			model='''impira/layoutlm-document-qa'''			,			tokenizer=a_			,			revision='''3dc6de3'''			,			)
     SCREAMING_SNAKE_CASE__: Any=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: List[str]=   '''What is the invoice number?'''

     SCREAMING_SNAKE_CASE__: Optional[Any]=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.4251, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.0819, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
         ]			,			)

     SCREAMING_SNAKE_CASE__: Optional[Any]=   dqa_pipeline({'''image''': image, '''question''': question}			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.4251, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.0819, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
         ]			,			)

     SCREAMING_SNAKE_CASE__: Tuple=   dqa_pipeline(
         [{'''image''': image, '''question''': question}, {'''image''': image, '''question''': question}]			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             [
                 {'''score''': 0.4251, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
                 {'''score''': 0.0819, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
             ]
         ]
         * 2			,			)

     SCREAMING_SNAKE_CASE__: Tuple=   list(zip(*apply_tesseract(load_image(a_ )			,			a_			,			'''''' ) ) )

     # This model should also work if `image` is set to None
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   dqa_pipeline({'''image''': None, '''word_boxes''': word_boxes, '''question''': question}			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.4251, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.0819, '''answer''': '''1110212019''', '''start''': 23, '''end''': 23},
         ]			,			)
    @slow
    @require_torch
    @require_pytesseract
    @require_vision
    def     UpperCamelCase_					(	self )							->       int:
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   AutoTokenizer.from_pretrained(
         '''impira/layoutlm-document-qa'''			,			revision='''3dc6de3'''			,			add_prefix_space=a_ )
     SCREAMING_SNAKE_CASE__: int=   pipeline(
         '''document-question-answering'''			,			model='''impira/layoutlm-document-qa'''			,			tokenizer=a_			,			revision='''3dc6de3'''			,			max_seq_len=50			,			)
     SCREAMING_SNAKE_CASE__: Tuple=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: List[Any]=   '''What is the invoice number?'''

     SCREAMING_SNAKE_CASE__: Any=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.9999, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.9998, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
         ]			,			)

     SCREAMING_SNAKE_CASE__: Optional[int]=   dqa_pipeline(
         [{'''image''': image, '''question''': question}, {'''image''': image, '''question''': question}]			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             [
                 {'''score''': 0.9999, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
                 {'''score''': 0.9998, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             ]
         ]
         * 2			,			)

     SCREAMING_SNAKE_CASE__: Optional[Any]=   list(zip(*apply_tesseract(load_image(a_ )			,			a_			,			'''''' ) ) )

     # This model should also work if `image` is set to None
     SCREAMING_SNAKE_CASE__: Dict=   dqa_pipeline({'''image''': None, '''word_boxes''': word_boxes, '''question''': question}			,			top_k=2 )
     self.assertEqual(
         nested_simplify(a_			,			decimals=4 )			,			[
             {'''score''': 0.9999, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
             {'''score''': 0.9998, '''answer''': '''us-001''', '''start''': 16, '''end''': 16},
         ]			,			)
    @slow
    @require_torch
    def     UpperCamelCase_					(	self )							->       Optional[int]:
     SCREAMING_SNAKE_CASE__: str=   pipeline(
         '''document-question-answering'''			,			model='''naver-clova-ix/donut-base-finetuned-docvqa'''			,			tokenizer=AutoTokenizer.from_pretrained('''naver-clova-ix/donut-base-finetuned-docvqa''' )			,			feature_extractor='''naver-clova-ix/donut-base-finetuned-docvqa'''			,			)

     SCREAMING_SNAKE_CASE__: Optional[int]=   INVOICE_URL
     SCREAMING_SNAKE_CASE__: Optional[int]=   '''What is the invoice number?'''
     SCREAMING_SNAKE_CASE__: Tuple=   dqa_pipeline(image=a_			,			question=a_			,			top_k=2 )
     self.assertEqual(nested_simplify(a_			,			decimals=4 )			,			[{'''answer''': '''us-001'''}] )



    @require_tf
    @unittest.skip('''Document question answering not implemented in TF''' )
    def     UpperCamelCase_					(	self )							->       Union[str, Any]:
     pass






import itertools
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Union

import pandas as pd
import pyarrow as pa

import datasets
import datasets.config
from datasets.features.features import require_storage_cast
from datasets.table import table_cast
from datasets.utils.py_utils import Literal


_lowerCAmelCase	:   Any    =   datasets.utils.logging.get_logger(__name__)

_lowerCAmelCase	:   Any    =   ["names", "prefix"]
_lowerCAmelCase	:   str    =   ["warn_bad_lines", "error_bad_lines", "mangle_dupe_cols"]
_lowerCAmelCase	:   List[str]    =   ["encoding_errors", "on_bad_lines"]
_lowerCAmelCase	:   int    =   ["date_format"]


@dataclass
class 	__snake_case   ( datasets.BuilderConfig ):
		SCREAMING_SNAKE_CASE__								=	","
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	"infer"
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	False
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	False
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	"."
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	'"'
		SCREAMING_SNAKE_CASE__								=	0
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	0
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	False
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	10000
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	"strict"
		SCREAMING_SNAKE_CASE__								=	"error"
		SCREAMING_SNAKE_CASE__								=	None
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						if self.delimiter is not None:
										lowerCAmelCase__		  =  self.delimiter
						if self.column_names is not None:
										lowerCAmelCase__		  =  self.column_names



		@property
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						lowerCAmelCase__		  =  {
						    'sep': self.sep,
						    'header': self.header,
						    'names': self.names,
						    'index_col': self.index_col,
						    'usecols': self.usecols,
						    'prefix': self.prefix,
						    'mangle_dupe_cols': self.mangle_dupe_cols,
						    'engine': self.engine,
						    'converters': self.converters,
						    'true_values': self.true_values,
						    'false_values': self.false_values,
						    'skipinitialspace': self.skipinitialspace,
						    'skiprows': self.skiprows,
						    'nrows': self.nrows,
						    'na_values': self.na_values,
						    'keep_default_na': self.keep_default_na,
						    'na_filter': self.na_filter,
						    'verbose': self.verbose,
						    'skip_blank_lines': self.skip_blank_lines,
						    'thousands': self.thousands,
						    'decimal': self.decimal,
						    'lineterminator': self.lineterminator,
						    'quotechar': self.quotechar,
						    'quoting': self.quoting,
						    'escapechar': self.escapechar,
						    'comment': self.comment,
						    'encoding': self.encoding,
						    'dialect': self.dialect,
						    'error_bad_lines': self.error_bad_lines,
						    'warn_bad_lines': self.warn_bad_lines,
						    'skipfooter': self.skipfooter,
						    'doublequote': self.doublequote,
						    'memory_map': self.memory_map,
						    'float_precision': self.float_precision,
						    'chunksize': self.chunksize,
						    'encoding_errors': self.encoding_errors,
						    'on_bad_lines': self.on_bad_lines,
						    'date_format': self.date_format,
						}

						# some kwargs must not be passed if they don't have a default value
						# some others are deprecated and we can also not pass them if they are the default value
						for pd_read_csv_parameter in _PANDAS_READ_CSV_NO_DEFAULT_PARAMETERS + _PANDAS_READ_CSV_DEPRECATED_PARAMETERS:
										if pd_read_csv_kwargs[pd_read_csv_parameter] == getattr(CsvConfig()    ,a_						):
														del pd_read_csv_kwargs[pd_read_csv_parameter]

        # Remove 2.0 new arguments
						if not (datasets.config.PANDAS_VERSION.major >= 2):
										for pd_read_csv_parameter in _PANDAS_READ_CSV_NEW_2_0_0_PARAMETERS:
														del pd_read_csv_kwargs[pd_read_csv_parameter]

        # Remove 1.3 new arguments
						if not (datasets.config.PANDAS_VERSION.major >= 1 and datasets.config.PANDAS_VERSION.minor >= 3):
										for pd_read_csv_parameter in _PANDAS_READ_CSV_NEW_1_3_0_PARAMETERS:
														del pd_read_csv_kwargs[pd_read_csv_parameter]

						return pd_read_csv_kwargs



class 	__snake_case   ( datasets.ArrowBasedBuilder ):
		SCREAMING_SNAKE_CASE__								=	CsvConfig
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						return datasets.DatasetInfo(features=self.config.features						)
		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_						):







						"""simple docstring"""
						if not self.config.data_files:
										raise ValueError(f'At least one data file must be specified, but got data_files={self.config.data_files}'						)
						lowerCAmelCase__		  =  dl_manager.download_and_extract(self.config.data_files						)
						if isinstance(a_    ,(str, list, tuple)						):
										lowerCAmelCase__		  =  data_files
										if isinstance(a_    ,a_						):
														lowerCAmelCase__		  =  [files]
										lowerCAmelCase__		  =  [dl_manager.iter_files(a_						) for file in files]
										return [datasets.SplitGenerator(name=datasets.Split.TRAIN    ,gen_kwargs={'files': files}						)]
						lowerCAmelCase__		  =  []
						for split_name, files in data_files.items():
										if isinstance(a_    ,a_						):
														lowerCAmelCase__		  =  [files]
										lowerCAmelCase__		  =  [dl_manager.iter_files(a_						) for file in files]
										splits.append(datasets.SplitGenerator(name=a_    ,gen_kwargs={'files': files}						)						)
						return splits
		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_						):







						"""simple docstring"""
						if self.config.features is not None:
										lowerCAmelCase__		  =  self.config.features.arrow_schema
										if all(not require_storage_cast(a_						) for feature in self.config.features.values()						):
														# cheaper cast
														lowerCAmelCase__		  =  pa.Table.from_arrays([pa_table[field.name] for field in schema]    ,schema=a_						)
										else:
														# more expensive cast; allows str <-> int/float or str to Audio for example
														lowerCAmelCase__		  =  table_cast(a_    ,a_						)
						return pa_table



		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_						):







						"""simple docstring"""
						lowerCAmelCase__		  =  self.config.features.arrow_schema if self.config.features else None
						# dtype allows reading an int column as str
						lowerCAmelCase__		  =  (
						    {
						        name: dtype.to_pandas_dtype() if not require_storage_cast(a_						) else object
						        for name, dtype, feature in zip(schema.names    ,schema.types    ,self.config.features.values()						)
						    }
						    if schema is not None
						    else None
						)
						for file_idx, file in enumerate(itertools.chain.from_iterable(a_						)						):
										lowerCAmelCase__		  =  pd.read_csv(a_    ,iterator=a_    ,dtype=a_    ,**self.config.pd_read_csv_kwargs						)
										try:
														for batch_idx, df in enumerate(a_						):
																		lowerCAmelCase__		  =  pa.Table.from_pandas(a_						)
																		# Uncomment for debugging (will print the Arrow table size and elements)
																		# logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
																		# logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
																		yield (file_idx, batch_idx), self._cast_table(a_						)
										except ValueError as e:
														logger.error(f'Failed to read file \'{file}\' with error {type(a_						)}: {e}'						)
														raise
