



from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
      import tensorflow as tf

      from transformers import (
          TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFXLMForMultipleChoice,
          TFXLMForQuestionAnsweringSimple,
          TFXLMForSequenceClassification,
          TFXLMForTokenClassification,
          TFXLMModel,
          TFXLMWithLMHeadModel,
          XLMConfig,
      )







class       _snake_case				:






   '''simple docstring'''






   def __init__(    self:     List[str]  ,lowerCamelCase_:     Dict  ,)	->      Optional[int]:
       UpperCAmelCase_     :       Optional[int]  		=					parent
       UpperCAmelCase_     :       List[str]  		=					13
       UpperCAmelCase_     :       Optional[int]  		=					7
       UpperCAmelCase_     :       Dict  		=					True
       UpperCAmelCase_     :       Union[str, Any]  		=					True
       UpperCAmelCase_     :       Any  		=					True
       UpperCAmelCase_     :       Union[str, Any]  		=					True
       UpperCAmelCase_     :       Tuple  		=					True
       UpperCAmelCase_     :       Union[str, Any]  		=					False
       UpperCAmelCase_     :       int  		=					False
       UpperCAmelCase_     :       Tuple  		=					False
       UpperCAmelCase_     :       Union[str, Any]  		=					2
       UpperCAmelCase_     :       Union[str, Any]  		=					99
       UpperCAmelCase_     :       int  		=					0
       UpperCAmelCase_     :       Tuple  		=					32
       UpperCAmelCase_     :       List[Any]  		=					2
       UpperCAmelCase_     :       int  		=					4
       UpperCAmelCase_     :       str  		=					0.1
       UpperCAmelCase_     :       int  		=					0.1
       UpperCAmelCase_     :       int  		=					512
       UpperCAmelCase_     :       int  		=					16
       UpperCAmelCase_     :       str  		=					2
       UpperCAmelCase_     :       List[Any]  		=					0.0_2
       UpperCAmelCase_     :       List[str]  		=					3
       UpperCAmelCase_     :       Optional[int]  		=					4
       UpperCAmelCase_     :       Any  		=					"""last"""
       UpperCAmelCase_     :       List[Any]  		=					True
       UpperCAmelCase_     :       List[str]  		=					None
       UpperCAmelCase_     :       Optional[Any]  		=					0


   def       A__    (    self:     str							)	->      int:
       UpperCAmelCase_     :       Union[str, Any]  		=					ids_tensor([self.batch_size, self.seq_length]  ,self.vocab_size							)
       UpperCAmelCase_     :       List[Any]  		=					random_attention_mask([self.batch_size, self.seq_length]  ,dtype=tf.floataa							)

       UpperCAmelCase_     :       List[Any]  		=					None
       if self.use_input_lengths:
           UpperCAmelCase_     :       Optional[int]  		=					(
               ids_tensor([self.batch_size]  ,vocab_size=2							) + self.seq_length - 2
           )  # small variation of seq_length

       UpperCAmelCase_     :       Optional[Any]  		=					None
       if self.use_token_type_ids:
           UpperCAmelCase_     :       Any  		=					ids_tensor([self.batch_size, self.seq_length]  ,self.n_langs							)

       UpperCAmelCase_     :       List[Any]  		=					None
       UpperCAmelCase_     :       Any  		=					None
       UpperCAmelCase_     :       List[str]  		=					None
       if self.use_labels:
           UpperCAmelCase_     :       str  		=					ids_tensor([self.batch_size]  ,self.type_sequence_label_size							)
           UpperCAmelCase_     :       int  		=					ids_tensor([self.batch_size, self.seq_length]  ,self.num_labels							)
           UpperCAmelCase_     :       Union[str, Any]  		=					ids_tensor([self.batch_size]  ,2  ,dtype=tf.floataa							)
           UpperCAmelCase_     :       str  		=					ids_tensor([self.batch_size]  ,self.num_choices							)

       UpperCAmelCase_     :       Union[str, Any]  		=					XLMConfig(
           vocab_size=self.vocab_size  ,n_special=self.n_special  ,emb_dim=self.hidden_size  ,n_layers=self.num_hidden_layers  ,n_heads=self.num_attention_heads  ,dropout=self.hidden_dropout_prob  ,attention_dropout=self.attention_probs_dropout_prob  ,gelu_activation=self.gelu_activation  ,sinusoidal_embeddings=self.sinusoidal_embeddings  ,asm=self.asm  ,causal=self.causal  ,n_langs=self.n_langs  ,max_position_embeddings=self.max_position_embeddings  ,initializer_range=self.initializer_range  ,summary_type=self.summary_type  ,use_proj=self.use_proj  ,bos_token_id=self.bos_token_id  ,)

       return (
           config,
           input_ids,
           token_type_ids,
           input_lengths,
           sequence_labels,
           token_labels,
           is_impossible_labels,
           choice_labels,
           input_mask,
       )


   def       A__    (    self:     List[Any]  ,lowerCamelCase_:     Optional[int]  ,lowerCamelCase_:     Optional[Any]  ,lowerCamelCase_:     Optional[int]  ,lowerCamelCase_:     List[str]  ,lowerCamelCase_:     int  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Tuple  ,lowerCamelCase_:     int  ,lowerCamelCase_:     str  ,)	->      List[str]:
       UpperCAmelCase_     :       Dict  		=					TFXLMModel(config=lowerCamelCase_							)
       UpperCAmelCase_     :       List[Any]  		=					{"""input_ids""": input_ids, """lengths""": input_lengths, """langs""": token_type_ids}
       UpperCAmelCase_     :       Optional[Any]  		=					model(lowerCamelCase_							)

       UpperCAmelCase_     :       Any  		=					[input_ids, input_mask]
       UpperCAmelCase_     :       int  		=					model(lowerCamelCase_							)
       self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, self.seq_length, self.hidden_size)							)


   def       A__    (    self:     Optional[Any]  ,lowerCamelCase_:     List[str]  ,lowerCamelCase_:     List[Any]  ,lowerCamelCase_:     List[str]  ,lowerCamelCase_:     Any  ,lowerCamelCase_:     str  ,lowerCamelCase_:     Tuple  ,lowerCamelCase_:     List[Any]  ,lowerCamelCase_:     Dict  ,lowerCamelCase_:     str  ,)	->      Tuple:
       UpperCAmelCase_     :       Tuple  		=					TFXLMWithLMHeadModel(lowerCamelCase_							)

       UpperCAmelCase_     :       Optional[int]  		=					{"""input_ids""": input_ids, """lengths""": input_lengths, """langs""": token_type_ids}
       UpperCAmelCase_     :       Any  		=					model(lowerCamelCase_							)

       UpperCAmelCase_     :       Any  		=					outputs

       self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.vocab_size)							)


   def       A__    (    self:     Union[str, Any]  ,lowerCamelCase_:     str  ,lowerCamelCase_:     Dict  ,lowerCamelCase_:     Optional[int]  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Optional[Any]  ,lowerCamelCase_:     str  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Optional[int]  ,lowerCamelCase_:     Dict  ,)	->      List[Any]:
       UpperCAmelCase_     :       List[str]  		=					TFXLMForQuestionAnsweringSimple(lowerCamelCase_							)

       UpperCAmelCase_     :       str  		=					{"""input_ids""": input_ids, """lengths""": input_lengths}

       UpperCAmelCase_     :       Tuple  		=					model(lowerCamelCase_							)

       self.parent.assertEqual(result.start_logits.shape  ,(self.batch_size, self.seq_length)							)
       self.parent.assertEqual(result.end_logits.shape  ,(self.batch_size, self.seq_length)							)


   def       A__    (    self:     Union[str, Any]  ,lowerCamelCase_:     List[str]  ,lowerCamelCase_:     Optional[Any]  ,lowerCamelCase_:     str  ,lowerCamelCase_:     Union[str, Any]  ,lowerCamelCase_:     List[Any]  ,lowerCamelCase_:     str  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Any  ,lowerCamelCase_:     int  ,)	->      Dict:
       UpperCAmelCase_     :       Optional[int]  		=					TFXLMForSequenceClassification(lowerCamelCase_							)

       UpperCAmelCase_     :       List[str]  		=					{"""input_ids""": input_ids, """lengths""": input_lengths}

       UpperCAmelCase_     :       Tuple  		=					model(lowerCamelCase_							)

       self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.type_sequence_label_size)							)


   def       A__    (    self:     int  ,lowerCamelCase_:     List[str]  ,lowerCamelCase_:     Any  ,lowerCamelCase_:     Optional[int]  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Optional[Any]  ,lowerCamelCase_:     Union[str, Any]  ,lowerCamelCase_:     str  ,lowerCamelCase_:     Union[str, Any]  ,lowerCamelCase_:     Any  ,)	->      Dict:
       UpperCAmelCase_     :       List[Any]  		=					self.num_labels
       UpperCAmelCase_     :       Optional[Any]  		=					TFXLMForTokenClassification(config=lowerCamelCase_							)
       UpperCAmelCase_     :       Tuple  		=					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
       UpperCAmelCase_     :       int  		=					model(lowerCamelCase_							)
       self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.num_labels)							)


   def       A__    (    self:     int  ,lowerCamelCase_:     Optional[Any]  ,lowerCamelCase_:     List[str]  ,lowerCamelCase_:     Any  ,lowerCamelCase_:     Any  ,lowerCamelCase_:     Any  ,lowerCamelCase_:     str  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Dict  ,lowerCamelCase_:     str  ,)	->      int:
       UpperCAmelCase_     :       str  		=					self.num_choices
       UpperCAmelCase_     :       Optional[int]  		=					TFXLMForMultipleChoice(config=lowerCamelCase_							)
       UpperCAmelCase_     :       Union[str, Any]  		=					tf.tile(tf.expand_dims(lowerCamelCase_  ,1							)  ,(1, self.num_choices, 1)							)
       UpperCAmelCase_     :       List[str]  		=					tf.tile(tf.expand_dims(lowerCamelCase_  ,1							)  ,(1, self.num_choices, 1)							)
       UpperCAmelCase_     :       Optional[Any]  		=					tf.tile(tf.expand_dims(lowerCamelCase_  ,1							)  ,(1, self.num_choices, 1)							)
       UpperCAmelCase_     :       List[str]  		=					{
           """input_ids""": multiple_choice_inputs_ids,
           """attention_mask""": multiple_choice_input_mask,
           """token_type_ids""": multiple_choice_token_type_ids,
       }
       UpperCAmelCase_     :       int  		=					model(lowerCamelCase_							)
       self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.num_choices)							)






   def       A__    (    self:     Optional[Any]							)	->      int:
       UpperCAmelCase_     :       Dict  		=					self.prepare_config_and_inputs()
       (
           (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, (
           UpperCAmelCase_
       )		, 
       )     :       Tuple  		=					config_and_inputs
       UpperCAmelCase_     :       Dict  		=					{
           """input_ids""": input_ids,
           """token_type_ids""": token_type_ids,
           """langs""": token_type_ids,
           """lengths""": input_lengths,
       }
       return config, inputs_dict







@require_tf
class       _snake_case				(     __snake_case ,							__snake_case ,							unittest.TestCase ):






   '''simple docstring'''






   A__      : Dict       =						(
       (
           TFXLMModel,
           TFXLMWithLMHeadModel,
           TFXLMForSequenceClassification,
           TFXLMForQuestionAnsweringSimple,
           TFXLMForTokenClassification,
           TFXLMForMultipleChoice,
       )
       if is_tf_available()
       else ()
   )
   A__      : int       =						(
       (TFXLMWithLMHeadModel,) if is_tf_available() else ()
   )  # TODO (PVP): Check other models whether language generation is also applicable
   A__      : Tuple       =						(
       {
           "feature-extraction": TFXLMModel,
           "fill-mask": TFXLMWithLMHeadModel,
           "question-answering": TFXLMForQuestionAnsweringSimple,
           "text-classification": TFXLMForSequenceClassification,
           "text-generation": TFXLMWithLMHeadModel,
           "token-classification": TFXLMForTokenClassification,
           "zero-shot": TFXLMForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   A__      : List[str]       =						False
   A__      : Optional[int]       =						False


   def       A__    (    self:     Optional[Any]  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Union[str, Any]  ,lowerCamelCase_:     Dict  ,lowerCamelCase_:     Optional[int]  ,lowerCamelCase_:     Optional[int]							)	->      Union[str, Any]:
       if (
           pipeline_test_casse_name == "QAPipelineTests"
           and tokenizer_name is not None
           and not tokenizer_name.endswith("""Fast"""							)
       ):
           # `QAPipelineTests` fails for a few models when the slower tokenizer are used.
           # (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
           # TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
           return True

       return False


   def       A__    (    self:     Optional[Any]							)	->      Dict:
       UpperCAmelCase_     :       Dict  		=					TFXLMModelTester(self							)
       UpperCAmelCase_     :       Dict  		=					ConfigTester(self  ,config_class=lowerCamelCase_  ,emb_dim=37							)


   def       A__    (    self:     Union[str, Any]							)	->      Union[str, Any]:
       self.config_tester.run_common_tests()


   def       A__    (    self:     int							)	->      Dict:
       UpperCAmelCase_     :       Dict  		=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_xlm_model(*lowerCamelCase_							)


   def       A__    (    self:     int							)	->      Dict:
       UpperCAmelCase_     :       Tuple  		=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_xlm_lm_head(*lowerCamelCase_							)


   def       A__    (    self:     List[str]							)	->      Dict:
       UpperCAmelCase_     :       Optional[Any]  		=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_xlm_qa(*lowerCamelCase_							)


   def       A__    (    self:     List[str]							)	->      Any:
       UpperCAmelCase_     :       List[str]  		=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_xlm_sequence_classif(*lowerCamelCase_							)


   def       A__    (    self:     int							)	->      Optional[Any]:
       UpperCAmelCase_     :       Optional[Any]  		=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_xlm_for_token_classification(*lowerCamelCase_							)


   def       A__    (    self:     Union[str, Any]							)	->      Dict:
       UpperCAmelCase_     :       Union[str, Any]  		=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_xlm_for_multiple_choice(*lowerCamelCase_							)






   @slow
   def       A__    (    self:     Optional[int]							)	->      Optional[Any]:
       for model_name in TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           UpperCAmelCase_     :       Tuple  		=					TFXLMModel.from_pretrained(lowerCamelCase_							)
           self.assertIsNotNone(lowerCamelCase_							)







@require_tf
class       _snake_case				(     unittest.TestCase ):






   '''simple docstring'''






   @slow
   def       A__    (    self:     Union[str, Any]							)	->      List[str]:
       UpperCAmelCase_     :       Tuple  		=					TFXLMWithLMHeadModel.from_pretrained("""xlm-mlm-en-2048"""							)
       UpperCAmelCase_     :       Union[str, Any]  		=					tf.convert_to_tensor([[14, 447]]  ,dtype=tf.intaa							)  # the president
       UpperCAmelCase_     :       List[Any]  		=					[
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
           14,
           447,
       ]  # the president the president the president the president the president the president the president the president the president the president
       # TODO(PVP): this and other input_ids I tried for generation give pretty bad results. Not sure why. Model might just not be made for auto-regressive inference
       UpperCAmelCase_     :       Optional[int]  		=					model.generate(lowerCamelCase_  ,do_sample=lowerCamelCase_							)
       self.assertListEqual(output_ids[0].numpy().tolist()  ,lowerCamelCase_							)





import getopt
import json
import os

# import numpy as np
import sys
from collections import OrderedDict

import datasets
import numpy as np
import torch
from modeling_frcnn import GeneralizedRCNN
from processing_image import Preprocess

from utils import Config
UpperCamelCase_									=   False
UpperCamelCase_									=   Config.from_pretrained('''unc-nlp/frcnn-vg-finetuned''')
UpperCamelCase_									=   datasets.Features(
    OrderedDict(
        {
            '''attr_ids''': datasets.Sequence(length=CONFIG.MAX_DETECTIONS, feature=datasets.Value('''float32''')),
            '''attr_probs''': datasets.Sequence(length=CONFIG.MAX_DETECTIONS, feature=datasets.Value('''float32''')),
            '''boxes''': datasets.ArrayaD((CONFIG.MAX_DETECTIONS, 4), dtype='''float32'''),
            '''img_id''': datasets.Value('''int32'''),
            '''obj_ids''': datasets.Sequence(length=CONFIG.MAX_DETECTIONS, feature=datasets.Value('''float32''')),
            '''obj_probs''': datasets.Sequence(length=CONFIG.MAX_DETECTIONS, feature=datasets.Value('''float32''')),
            '''roi_features''': datasets.ArrayaD((CONFIG.MAX_DETECTIONS, 2048), dtype='''float32'''),
            '''sizes''': datasets.Sequence(length=2, feature=datasets.Value('''float32''')),
            '''preds_per_image''': datasets.Value(dtype='''int32'''),
        }
    )
)







class       _snake_case				:






   '''simple docstring'''






   def __init__(    self:     Dict  ,lowerCamelCase_:     Optional[Any]=sys.argv[1:]							)	->      Optional[int]:
       UpperCAmelCase_     :       Union[str, Any]  		=					None
       UpperCAmelCase_     :       Any  		=					None
       UpperCAmelCase_     :       List[str]  		=					None
       UpperCAmelCase_     :       List[str]  		=					1
       UpperCAmelCase_		, UpperCAmelCase_     :       str  		=					getopt.getopt(lowerCamelCase_  ,"""i:o:b:s"""  ,["""inputdir=""", """outfile=""", """batch_size=""", """subset_list="""]							)
       for opt, arg in opts:
           if opt in ("-i", "--inputdir"):
               UpperCAmelCase_     :       List[Any]  		=					arg
           elif opt in ("-o", "--outfile"):
               UpperCAmelCase_     :       Optional[int]  		=					arg
           elif opt in ("-b", "--batch_size"):
               UpperCAmelCase_     :       Tuple  		=					int(lowerCamelCase_							)
           elif opt in ("-s", "--subset_list"):
               UpperCAmelCase_     :       Dict  		=					arg

       assert inputdir is not None  # and os.path.isdir(inputdir), f"{inputdir}"
       assert outputfile is not None and not os.path.isfile(lowerCamelCase_							), F'''{outputfile}'''
       if subset_list is not None:
           with open(os.path.realpath(lowerCamelCase_							)							) as f:
               UpperCAmelCase_     :       Union[str, Any]  		=					{self._vqa_file_split()[0] for x in tryload(lowerCamelCase_							)}
       else:
           UpperCAmelCase_     :       Optional[Any]  		=					None

       UpperCAmelCase_     :       Optional[int]  		=					CONFIG
       if torch.cuda.is_available():
           UpperCAmelCase_     :       Any  		=					"""cuda"""
       UpperCAmelCase_     :       str  		=					os.path.realpath(lowerCamelCase_							)
       UpperCAmelCase_     :       Any  		=					os.path.realpath(lowerCamelCase_							)
       UpperCAmelCase_     :       Optional[Any]  		=					Preprocess(self.config							)
       UpperCAmelCase_     :       List[str]  		=					GeneralizedRCNN.from_pretrained("""unc-nlp/frcnn-vg-finetuned"""  ,config=self.config							)
       UpperCAmelCase_     :       Optional[Any]  		=					batch_size if batch_size != 0 else 1
       UpperCAmelCase_     :       Optional[int]  		=					DEFAULT_SCHEMA


   def       A__    (    self:     str  ,lowerCamelCase_:     Dict							)	->      Union[str, Any]:
       UpperCAmelCase_     :       List[str]  		=					int(file.split("""."""							)[0].split("""_"""							)[-1]							)
       UpperCAmelCase_     :       int  		=					os.path.join(self.inputdir  ,lowerCamelCase_							)
       return (img_id, filepath)


   @property
   def       A__    (    self:     Tuple							)	->      List[str]:
       UpperCAmelCase_     :       int  		=					[]
       for i, file in enumerate(os.listdir(self.inputdir							)							):
           if self.subset_list is not None and i not in self.subset_list:
               continue
           batch.append(self._vqa_file_split(lowerCamelCase_							)							)
           if len(lowerCamelCase_							) == self.batch:
               UpperCAmelCase_     :       Tuple  		=					batch
               UpperCAmelCase_     :       Union[str, Any]  		=					[]
               yield list(map(lowerCamelCase_  ,zip(*lowerCamelCase_							)							)							)

       for i in range(1							):
           yield list(map(lowerCamelCase_  ,zip(*lowerCamelCase_							)							)							)






   def __call__(    self:     Any							)	->      Optional[Any]:
       # make writer
       if not TEST:
           UpperCAmelCase_     :       Tuple  		=					datasets.ArrowWriter(features=self.schema  ,path=self.outputfile							)
       # do file generator
       for i, (img_ids, filepaths) in enumerate(self.file_generator							):
           UpperCAmelCase_		, UpperCAmelCase_		, UpperCAmelCase_     :       str  		=					self.preprocess(lowerCamelCase_							)
           UpperCAmelCase_     :       Any  		=					self.model(
               lowerCamelCase_  ,lowerCamelCase_  ,scales_yx=lowerCamelCase_  ,padding="""max_detections"""  ,max_detections=self.config.MAX_DETECTIONS  ,pad_value=0  ,return_tensors="""np"""  ,location="""cpu"""  ,)
           UpperCAmelCase_     :       Dict  		=					output_dict.pop("""normalized_boxes"""							)
           if not TEST:
               UpperCAmelCase_     :       str  		=					np.array(lowerCamelCase_							)
               UpperCAmelCase_     :       int  		=					self.schema.encode_batch(lowerCamelCase_							)
               writer.write_batch(lowerCamelCase_							)
           if TEST:
               break
           # finalizer the writer
       if not TEST:
           UpperCAmelCase_		, UpperCAmelCase_     :       Dict  		=					writer.finalize()
           print(F'''Success! You wrote {num_examples} entry(s) and {num_bytes >> 20} mb'''							)







def       lowerCamelCase_  (    _a       :						int    ):



    '''simple docstring'''




    try:
        UpperCAmelCase_     :       Optional[int]  		=					json.load(_a    )
        try:
            UpperCAmelCase_     :       List[Any]  		=					list(data.keys()    )
        except Exception:
            UpperCAmelCase_     :       List[Any]  		=					[d["""img_id"""] for d in data]
    except Exception:
        try:
            UpperCAmelCase_     :       str  		=					eval(stream.read()    )
        except Exception:
            UpperCAmelCase_     :       List[Any]  		=					stream.read().split("""\n"""    )
    return data


if __name__ == "__main__":
      UpperCamelCase_									=   Extract(sys.argv[1:])
      extract()
      if not TEST:
            UpperCamelCase_									=   datasets.Dataset.from_file(extract.outputfile)
            # wala!
            # print(np.array(dataset[0:2]["roi_features"]).shape)
