"""simple docstring"""



import datasets
import faiss
import numpy as np
import streamlit as st
import torch
from elasticsearch import Elasticsearch
from elia_utils import (
    embed_questions_for_retrieval,
    make_qa_sas_model,
    qa_sas_generate,
    query_es_index,
    query_qa_dense_index,
)

import transformers
from transformers import AutoModel, AutoModelForSeqaSeqLM, AutoTokenizer


SCREAMING_SNAKE_CASE__:List[Any]									=			'bart'
SCREAMING_SNAKE_CASE__:Tuple									=			True



@st.cache(allow_output_mutation=UpperCAmelCase__				)
def 	_lowerCamelCase(	):



       if LOAD_DENSE_INDEX:
              __a       =    AutoTokenizer.from_pretrained("yjernite/retribert-base-uncased"				)
              __a       =    AutoModel.from_pretrained("yjernite/retribert-base-uncased"				).to("cuda:0"				)
              __a       =    qar_model.eval()
       else:
              __a ,   __a       =    (None, None)
       if MODEL_TYPE == "bart":
              __a       =    AutoTokenizer.from_pretrained("yjernite/bart_eli5"				)
              __a       =    AutoModelForSeqaSeqLM.from_pretrained("yjernite/bart_eli5"				).to("cuda:0"				)
              __a       =    torch.load("seq2seq_models/eli5_bart_model_blm_2.pth"				)
              sas_model.load_state_dict(save_dict["model"]				)
              __a       =    sas_model.eval()
       else:
              __a ,   __a       =    make_qa_sas_model(
                  model_name="t5-small"   ,    from_file="seq2seq_models/eli5_t5_model_1024_4.pth"   ,    device="cuda:0"				)
       return (qar_tokenizer, qar_model, sas_tokenizer, sas_model)



@st.cache(allow_output_mutation=UpperCAmelCase__				)
def 	_lowerCamelCase(	):



       if LOAD_DENSE_INDEX:
              __a       =    faiss.StandardGpuResources()
              __a       =    datasets.load_dataset(path="wiki_snippets"   ,    name="wiki40b_en_100_0"				)["train"]
              __a       =    np.memmap(
                  "wiki40b_passages_reps_32_l-8_h-768_b-512-512.dat"   ,    dtype="float32"   ,    mode="r"   ,    shape=(wikiaab_passages.num_rows, 1_2_8)   ,    )
              __a       =    faiss.IndexFlatIP(1_2_8				)
              __a       =    faiss.index_cpu_to_gpu(UpperCAmelCase__   ,    1   ,    UpperCAmelCase__				)
              wikiaab_gpu_index_flat.add(UpperCAmelCase__				)  # TODO fix for larger GPU
       else:
              __a ,   __a       =    (None, None)
       __a       =    Elasticsearch([{"host": "localhost", "port": "9200"}]				)
       return (wikiaab_passages, wikiaab_gpu_index_flat, es_client)



@st.cache(allow_output_mutation=UpperCAmelCase__				)
def 	_lowerCamelCase(	):
       __a       =    datasets.load_dataset("eli5"   ,    name="LFQA_reddit"				)
       __a       =    elia["train_eli5"]
       __a       =    np.memmap(
           "eli5_questions_reps.dat"   ,    dtype="float32"   ,    mode="r"   ,    shape=(elia_train.num_rows, 1_2_8)				)
       __a       =    faiss.IndexFlatIP(1_2_8				)
       eli5_train_q_index.add(UpperCAmelCase__				)
       return (elia_train, eli5_train_q_index)


SCREAMING_SNAKE_CASE__:Optional[Any]									=			load_indexes()
SCREAMING_SNAKE_CASE__:Tuple									=			load_models()
SCREAMING_SNAKE_CASE__:Tuple									=			load_train_data()



def 	_lowerCamelCase(	a   ,    a=1_0				):
       __a       =    embed_questions_for_retrieval([question]   ,    UpperCAmelCase__   ,    UpperCAmelCase__				)
       __a ,   __a       =    eli5_train_q_index.search(UpperCAmelCase__   ,    UpperCAmelCase__				)
       __a       =    [elia_train[int(UpperCAmelCase__				)] for i in I[0]]
       return nn_examples



def 	_lowerCamelCase(	a   ,    a="wiki40b"   ,    a="dense"   ,    a=1_0				):



       if source == "none":
              __a ,   __a       =    (" <P> ".join(["" for _ in range(1_1				)]				).strip(), [])
       else:
              if method == "dense":
                     __a ,   __a       =    query_qa_dense_index(
                         UpperCAmelCase__   ,    UpperCAmelCase__   ,    UpperCAmelCase__   ,    UpperCAmelCase__   ,    UpperCAmelCase__   ,    UpperCAmelCase__				)
              else:
                     __a ,   __a       =    query_es_index(
                         UpperCAmelCase__   ,    UpperCAmelCase__   ,    index_name="english_wiki40b_snippets_100w"   ,    n_results=UpperCAmelCase__   ,    )
       __a       =    [
           (res["article_title"], res["section_title"].strip(), res["score"], res["passage_text"]) for res in hit_lst
       ]
       __a       =    "question: {} context: {}".format(UpperCAmelCase__   ,    UpperCAmelCase__				)
       return question_doc, support_list



@st.cache(
    hash_funcs={
        torch.Tensor: (lambda a				: None),
        transformers.models.bart.tokenization_bart.BartTokenizer: (lambda a				: None),
    }				)
def 	_lowerCamelCase(	a   ,    a   ,    a   ,    a=6_4   ,    a=2_5_6   ,    a=False   ,    a=2   ,    a=0.95   ,    a=0.8				):



       with torch.no_grad():
              __a       =    qa_sas_generate(
                  UpperCAmelCase__   ,    UpperCAmelCase__   ,    UpperCAmelCase__   ,    num_answers=1   ,    num_beams=UpperCAmelCase__   ,    min_len=UpperCAmelCase__   ,    max_len=UpperCAmelCase__   ,    do_sample=UpperCAmelCase__   ,    temp=UpperCAmelCase__   ,    top_p=UpperCAmelCase__   ,    top_k=UpperCAmelCase__   ,    max_input_length=1_0_2_4   ,    device="cuda:0"   ,    )[0]
       return (answer, support_list)


st.title("""Long Form Question Answering with ELI5""")

# Start sidebar
SCREAMING_SNAKE_CASE__:List[str]									=			'<img src=\'https://huggingface.co/front/assets/huggingface_logo.svg\'>'
SCREAMING_SNAKE_CASE__:int									=			'\n<html>\n  <head>\n    <style>\n      .img-container {\n        padding-left: 90px;\n        padding-right: 90px;\n        padding-top: 50px;\n        padding-bottom: 50px;\n        background-color: #f0f3f9;\n      }\n    </style>\n  </head>\n  <body>\n    <span class="img-container"> <!-- Inline parent element -->\n      %s\n    </span>\n  </body>\n</html>\n' % (
    header_html,
)
st.sidebar.markdown(
    header_full,
    unsafe_allow_html=True,
)

# Long Form QA with ELI5 and Wikipedia
SCREAMING_SNAKE_CASE__:List[str]									=			'\nThis demo presents a model trained to [provide long-form answers to open-domain questions](https://yjernite.github.io/lfqa.html).\nFirst, a document retriever fetches a set of relevant Wikipedia passages given the question from the [Wiki40b](https://research.google/pubs/pub49029/) dataset,\na pre-processed fixed snapshot of Wikipedia.\n'
st.sidebar.markdown(description, unsafe_allow_html=True)

SCREAMING_SNAKE_CASE__:int									=			[
    'Answer the question',
    'View the retrieved document only',
    'View the most similar ELI5 question and answer',
    'Show me everything, please!',
]
SCREAMING_SNAKE_CASE__:Optional[Any]									=			st.sidebar.checkbox("""Demo options""")
if demo_options:
   SCREAMING_SNAKE_CASE__:Dict									=			st.sidebar.selectbox(
       """""",
       action_list,
       index=3,
   )
   SCREAMING_SNAKE_CASE__:Any									=			action_list.index(action_st)
   SCREAMING_SNAKE_CASE__:int									=			st.sidebar.selectbox(
       """""",
       ["""Show full text of passages""", """Show passage section titles"""],
       index=0,
   )
   SCREAMING_SNAKE_CASE__:Tuple									=			show_type == 'Show full text of passages'
else:
   SCREAMING_SNAKE_CASE__:Optional[int]									=			3
   SCREAMING_SNAKE_CASE__:Optional[int]									=			True

SCREAMING_SNAKE_CASE__:int									=			st.sidebar.checkbox("""Retrieval options""")
if retrieval_options:
   SCREAMING_SNAKE_CASE__:Optional[int]									=			'\n    ### Information retriever options\n\n    The **sparse** retriever uses ElasticSearch, while the **dense** retriever uses max-inner-product search between a question and passage embedding\n    trained using the [ELI5](https://arxiv.org/abs/1907.09190) questions-answer pairs.\n    The answer is then generated by sequence to sequence model which takes the question and retrieved document as input.\n    '
   st.sidebar.markdown(retriever_info)
   SCREAMING_SNAKE_CASE__:str									=			st.sidebar.selectbox("""Which Wikipedia format should the model use?""", ["""wiki40b""", """none"""])
   SCREAMING_SNAKE_CASE__:Optional[int]									=			st.sidebar.selectbox("""Which Wikipedia indexer should the model use?""", ["""dense""", """sparse""", """mixed"""])
else:
   SCREAMING_SNAKE_CASE__:List[str]									=			'wiki40b'
   SCREAMING_SNAKE_CASE__:Union[str, Any]									=			'dense'

SCREAMING_SNAKE_CASE__:Optional[int]									=			'beam'
SCREAMING_SNAKE_CASE__:Optional[Any]									=			2
SCREAMING_SNAKE_CASE__:Any									=			64
SCREAMING_SNAKE_CASE__:Dict									=			256
SCREAMING_SNAKE_CASE__:Optional[int]									=			None
SCREAMING_SNAKE_CASE__:Optional[Any]									=			None
SCREAMING_SNAKE_CASE__:List[Any]									=			st.sidebar.checkbox("""Generation options""")
if generate_options:
   SCREAMING_SNAKE_CASE__:Any									=			'\n    ### Answer generation options\n\n    The sequence-to-sequence model was initialized with [BART](https://huggingface.co/facebook/bart-large)\n    weights and fine-tuned on the ELI5 QA pairs and retrieved documents. You can use the model for greedy decoding with\n    **beam** search, or **sample** from the decoder\'s output probabilities.\n    '
   st.sidebar.markdown(generate_info)
   SCREAMING_SNAKE_CASE__:List[str]									=			st.sidebar.selectbox("""Would you like to use beam search or sample an answer?""", ["""beam""", """sampled"""])
   SCREAMING_SNAKE_CASE__:int									=			st.sidebar.slider(
       """Minimum generation length""", min_value=8, max_value=256, value=64, step=8, format=None, key=None
   )
   SCREAMING_SNAKE_CASE__:Optional[int]									=			st.sidebar.slider(
       """Maximum generation length""", min_value=64, max_value=512, value=256, step=16, format=None, key=None
   )
   if sampled == "beam":
      SCREAMING_SNAKE_CASE__:str									=			st.sidebar.slider("""Beam size""", min_value=1, max_value=8, value=2, step=None, format=None, key=None)
   else:
      SCREAMING_SNAKE_CASE__:str									=			st.sidebar.slider(
          """Nucleus sampling p""", min_value=0.1, max_value=1.0, value=0.95, step=0.01, format=None, key=None
      )
      SCREAMING_SNAKE_CASE__:List[str]									=			st.sidebar.slider(
          """Temperature""", min_value=0.1, max_value=1.0, value=0.7, step=0.01, format=None, key=None
      )
      SCREAMING_SNAKE_CASE__:str									=			None

# start main text
SCREAMING_SNAKE_CASE__:Union[str, Any]									=			[
    '<MY QUESTION>',
    'How do people make chocolate?',
    'Why do we get a fever when we are sick?',
    'How can different animals perceive different colors?',
    'What is natural language processing?',
    'What\'s the best way to treat a sunburn?',
    'What exactly are vitamins ?',
    'How does nuclear energy provide electricity?',
    'What\'s the difference between viruses and bacteria?',
    'Why are flutes classified as woodwinds when most of them are made out of metal ?',
    'Why do people like drinking coffee even though it tastes so bad?',
    'What happens when wine ages? How does it make the wine taste better?',
    'If an animal is an herbivore, where does it get the protein that it needs to survive if it only eats grass?',
    'How can we set a date to the beginning or end of an artistic period? Doesn\'t the change happen gradually?',
    'How does New Zealand have so many large bird predators?',
]
SCREAMING_SNAKE_CASE__:Tuple									=			st.selectbox(
    """What would you like to ask? ---- select <MY QUESTION> to enter a new query""",
    questions_list,
    index=1,
)
if question_s == "<MY QUESTION>":
   SCREAMING_SNAKE_CASE__:List[Any]									=			st.text_input("""Enter your question here:""", """""")
else:
   SCREAMING_SNAKE_CASE__:str									=			question_s

if st.button("""Show me!"""):
   if action in [0, 1, 3]:
      if index_type == "mixed":
         SCREAMING_SNAKE_CASE__:Union[str, Any]									=			make_support(question, source=wiki_source, method="""dense""", n_results=10)
         SCREAMING_SNAKE_CASE__:Tuple									=			make_support(question, source=wiki_source, method="""sparse""", n_results=10)
         SCREAMING_SNAKE_CASE__:str									=			[]
         for res_d, res_s in zip(support_list_dense, support_list_sparse):
            if tuple(res_d) not in support_list:
               support_list += [tuple(res_d)]
            if tuple(res_s) not in support_list:
               support_list += [tuple(res_s)]
         SCREAMING_SNAKE_CASE__:List[str]									=			support_list[:10]
         SCREAMING_SNAKE_CASE__:int									=			'<P> ' + ' <P> '.join([res[-1] for res in support_list])
      else:
         SCREAMING_SNAKE_CASE__:Any									=			make_support(question, source=wiki_source, method=index_type, n_results=10)
   if action in [0, 3]:
      SCREAMING_SNAKE_CASE__:List[Any]									=			answer_question(
          question_doc,
          sas_model,
          sas_tokenizer,
          min_len=min_len,
          max_len=int(max_len),
          sampling=(sampled == """sampled"""),
          n_beams=n_beams,
          top_p=top_p,
          temp=temp,
      )
      st.markdown("""### The model generated answer is:""")
      st.write(answer)
   if action in [0, 1, 3] and wiki_source != "none":
      st.markdown("""--- \n ### The model is drawing information from the following Wikipedia passages:""")
      for i, res in enumerate(support_list):
         SCREAMING_SNAKE_CASE__:Dict									=			'https://en.wikipedia.org/wiki/{}'.format(res[0].replace(""" """, """_"""))
         SCREAMING_SNAKE_CASE__:Optional[Any]									=			res[1].strip()
         if sec_titles == "":
            SCREAMING_SNAKE_CASE__:Tuple									=			'[{}]({})'.format(res[0], wiki_url)
         else:
            SCREAMING_SNAKE_CASE__:Union[str, Any]									=			sec_titles.split(""" & """)
            SCREAMING_SNAKE_CASE__:int									=			' & '.join(
                ["""[{}]({}#{})""".format(sec.strip(), wiki_url, sec.strip().replace(""" """, """_""")) for sec in sec_list]
            )
         st.markdown(
             """{0:02d} - **Article**: {1:<18} <br>  _Section_: {2}""".format(i + 1, res[0], sections),
             unsafe_allow_html=True,
         )
         if show_passages:
            st.write(
                """> <span style=\"font-family:arial; font-size:10pt;\">""" + res[-1] + """</span>""", unsafe_allow_html=True
            )
   if action in [2, 3]:
      SCREAMING_SNAKE_CASE__:Any									=			find_nearest_training(question)
      SCREAMING_SNAKE_CASE__:Optional[Any]									=			nn_train_list[0]
      st.markdown(
          """--- \n ### The most similar question in the ELI5 training set was: \n\n {}""".format(train_exple["""title"""])
      )
      SCREAMING_SNAKE_CASE__:Optional[int]									=			[
          '{}. {}'.format(i + 1, """  \n""".join([line.strip() for line in ans.split("""\n""") if line.strip() != """"""]))
          for i, (ans, sc) in enumerate(zip(train_exple["""answers"""]["""text"""], train_exple["""answers"""]["""score"""]))
          if i == 0 or sc > 2
      ]
      st.markdown("""##### Its answers were: \n\n {}""".format("""\n""".join(answers_st)))


SCREAMING_SNAKE_CASE__:List[str]									=			'\n---\n\n**Disclaimer**\n\n*The intent of this app is to provide some (hopefully entertaining) insights into the behavior of a current LFQA system.\nEvaluating biases of such a model and ensuring factual generations are still very much open research problems.\nTherefore, until some significant progress is achieved, we caution against using the generated answers for practical purposes.*\n'




st.sidebar.markdown(disclaimer, unsafe_allow_html=True)





import unittest

import numpy as np

from transformers.testing_utils import require_pytesseract, require_torch
from transformers.utils import is_pytesseract_available, is_torch_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
     import torch

if is_pytesseract_available():
     from PIL import Image

     from transformers import LayoutLMvaImageProcessor





class  lowerCamelCase__	(    unittest.TestCase):
     """simple docstring"""



     def __init__(self					,      __a					,      __a=7					,      __a=3					,      __a=18					,      __a=30					,      __a=4_00					,      __a=True					,      __a=None					,      __a=True					,      ):






           '''simple docstring'''



           lowerCamelCase             =		size if size is not None else {"height": 18, "width": 18}
           lowerCamelCase             =		parent
           lowerCamelCase             =		batch_size
           lowerCamelCase             =		num_channels
           lowerCamelCase             =		image_size
           lowerCamelCase             =		min_resolution
           lowerCamelCase             =		max_resolution
           lowerCamelCase             =		do_resize
           lowerCamelCase             =		size
           lowerCamelCase             =		apply_ocr







     def     _a   (self     ):






           '''simple docstring'''



           return {"do_resize": self.do_resize, "size": self.size, "apply_ocr": self.apply_ocr}





@require_torch
@require_pytesseract
class  lowerCamelCase__	(    UpperCAmelCase_							,     unittest.TestCase):
     """simple docstring"""



     _A      =      LayoutLMvaImageProcessor if is_pytesseract_available() else None







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		LayoutLMvaImageProcessingTester(self     )







     @property
     def     _a   (self     ):






           '''simple docstring'''



           return self.image_processor_tester.prepare_image_processor_dict()







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		self.image_processing_class(**self.image_processor_dict     )
           self.assertTrue(hasattr(__a					,      "do_resize"     )     )
           self.assertTrue(hasattr(__a					,      "size"     )     )
           self.assertTrue(hasattr(__a					,      "apply_ocr"     )     )







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		self.image_processing_class.from_dict(self.image_processor_dict     )
           self.assertEqual(image_processor.size					,      {"height": 18, "width": 18}     )

           lowerCamelCase             =		self.image_processing_class.from_dict(self.image_processor_dict					,      size=42     )
           self.assertEqual(image_processor.size					,      {"height": 42, "width": 42}     )







     def     _a   (self     ):






           '''simple docstring'''



           pass







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		self.image_processing_class(**self.image_processor_dict     )
           # create random PIL images
           lowerCamelCase             =		prepare_image_inputs(self.image_processor_tester					,      equal_resolution=__a     )
           for image in image_inputs:
                 self.assertIsInstance(__a					,      Image.Image     )

           # Test not batched input
           lowerCamelCase             =		image_processing(image_inputs[0]					,      return_tensors="pt"     )
           self.assertEqual(
               encoding.pixel_values.shape					,      (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,      )

           self.assertIsInstance(encoding.words					,      __a     )
           self.assertIsInstance(encoding.boxes					,      __a     )

           # Test batched
           lowerCamelCase             =		image_processing(__a					,      return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape					,      (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,      )







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		self.image_processing_class(**self.image_processor_dict     )
           # create random numpy tensors
           lowerCamelCase             =		prepare_image_inputs(self.image_processor_tester					,      equal_resolution=__a					,      numpify=__a     )
           for image in image_inputs:
                 self.assertIsInstance(__a					,      np.ndarray     )

           # Test not batched input
           lowerCamelCase             =		image_processing(image_inputs[0]					,      return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape					,      (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,      )

           # Test batched
           lowerCamelCase             =		image_processing(__a					,      return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape					,      (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,      )







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		self.image_processing_class(**self.image_processor_dict     )
           # create random PyTorch tensors
           lowerCamelCase             =		prepare_image_inputs(self.image_processor_tester					,      equal_resolution=__a					,      torchify=__a     )
           for image in image_inputs:
                 self.assertIsInstance(__a					,      torch.Tensor     )

           # Test not batched input
           lowerCamelCase             =		image_processing(image_inputs[0]					,      return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape					,      (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,      )

           # Test batched
           lowerCamelCase             =		image_processing(__a					,      return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape					,      (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,      )







     def     _a   (self     ):






           '''simple docstring'''



           lowerCamelCase             =		LayoutLMvaImageProcessor()

           from datasets import load_dataset

           lowerCamelCase             =		load_dataset("hf-internal-testing/fixtures_docvqa"					,      split="test"     )

           lowerCamelCase             =		Image.open(ds[0]["file"]     ).convert("RGB"     )

           lowerCamelCase             =		image_processing(__a					,      return_tensors="pt"     )

           self.assertEqual(encoding.pixel_values.shape					,      (1, 3, 2_24, 2_24)     )
           self.assertEqual(len(encoding.words     )					,      len(encoding.boxes     )     )

           # fmt: off
           # the words and boxes were obtained with Tesseract 4.1.1
           lowerCamelCase             =		[["11:14", "to", "11:39", "a.m", "11:39", "to", "11:44", "a.m.", "11:44", "a.m.", "to", "12:25", "p.m.", "12:25", "to", "12:58", "p.m.", "12:58", "to", "4:00", "p.m.", "2:00", "to", "5:00", "p.m.", "Coffee", "Break", "Coffee", "will", "be", "served", "for", "men", "and", "women", "in", "the", "lobby", "adjacent", "to", "exhibit", "area.", "Please", "move", "into", "exhibit", "area.", "(Exhibits", "Open)", "TRRF", "GENERAL", "SESSION", "(PART", "|)", "Presiding:", "Lee", "A.", "Waller", "TRRF", "Vice", "President", "“Introductory", "Remarks”", "Lee", "A.", "Waller,", "TRRF", "Vice", "Presi-", "dent", "Individual", "Interviews", "with", "TRRF", "Public", "Board", "Members", "and", "Sci-", "entific", "Advisory", "Council", "Mem-", "bers", "Conducted", "by", "TRRF", "Treasurer", "Philip", "G.", "Kuehn", "to", "get", "answers", "which", "the", "public", "refrigerated", "warehousing", "industry", "is", "looking", "for.", "Plus", "questions", "from", "the", "floor.", "Dr.", "Emil", "M.", "Mrak,", "University", "of", "Cal-", "ifornia,", "Chairman,", "TRRF", "Board;", "Sam", "R.", "Cecil,", "University", "of", "Georgia", "College", "of", "Agriculture;", "Dr.", "Stanley", "Charm,", "Tufts", "University", "School", "of", "Medicine;", "Dr.", "Robert", "H.", "Cotton,", "ITT", "Continental", "Baking", "Company;", "Dr.", "Owen", "Fennema,", "University", "of", "Wis-", "consin;", "Dr.", "Robert", "E.", "Hardenburg,", "USDA.", "Questions", "and", "Answers", "Exhibits", "Open", "Capt.", "Jack", "Stoney", "Room", "TRRF", "Scientific", "Advisory", "Council", "Meeting", "Ballroom", "Foyer"]]  # noqa: E231
           lowerCamelCase             =		[[[1_41, 57, 2_14, 69], [2_28, 58, 2_52, 69], [1_41, 75, 2_16, 88], [2_30, 79, 2_80, 88], [1_42, 2_60, 2_18, 2_73], [2_30, 2_61, 2_55, 2_73], [1_43, 2_79, 2_18, 2_90], [2_31, 2_82, 2_90, 2_91], [1_43, 3_42, 2_18, 3_54], [2_31, 3_45, 2_89, 3_55], [2_02, 3_62, 2_27, 3_73], [1_43, 3_79, 2_20, 3_92], [2_31, 3_82, 2_91, 3_94], [1_44, 7_14, 2_20, 7_26], [2_31, 7_15, 2_56, 7_26], [1_44, 7_32, 2_20, 7_45], [2_32, 7_36, 2_91, 7_47], [1_44, 7_69, 2_18, 7_82], [2_31, 7_70, 2_56, 7_82], [1_41, 7_88, 2_02, 8_01], [2_15, 7_91, 2_74, 8_04], [1_43, 8_26, 2_04, 8_38], [2_15, 8_26, 2_40, 8_38], [1_42, 8_44, 2_02, 8_57], [2_15, 8_47, 2_74, 8_59], [3_34, 57, 4_27, 69], [4_40, 57, 5_22, 69], [3_69, 75, 4_61, 88], [4_69, 75, 5_16, 88], [5_28, 76, 5_62, 88], [5_70, 76, 6_67, 88], [6_75, 75, 7_11, 87], [7_21, 79, 7_78, 88], [7_89, 75, 8_40, 88], [3_69, 97, 4_70, 1_07], [4_84, 94, 5_07, 1_06], [5_18, 94, 5_62, 1_07], [5_76, 94, 6_55, 1_10], [6_68, 94, 7_92, 1_09], [8_04, 95, 8_29, 1_07], [3_69, 1_13, 4_65, 1_25], [4_77, 1_16, 5_47, 1_25], [5_62, 1_13, 6_58, 1_25], [6_71, 1_16, 7_48, 1_25], [7_61, 1_13, 8_11, 1_25], [3_69, 1_31, 4_65, 1_43], [4_77, 1_33, 5_48, 1_43], [5_63, 1_30, 6_98, 1_45], [7_10, 1_30, 8_02, 1_46], [3_36, 1_71, 4_12, 1_83], [4_23, 1_71, 5_72, 1_83], [5_82, 1_70, 7_16, 1_84], [7_28, 1_71, 8_17, 1_87], [8_29, 1_71, 8_44, 1_86], [3_38, 1_97, 4_82, 2_12], [5_07, 1_96, 5_57, 2_09], [5_69, 1_96, 5_95, 2_08], [6_10, 1_96, 7_02, 2_09], [5_05, 2_14, 5_83, 2_26], [5_95, 2_14, 6_56, 2_27], [6_70, 2_15, 8_07, 2_27], [3_35, 2_59, 5_43, 2_74], [5_56, 2_59, 7_08, 2_72], [3_72, 2_79, 4_22, 2_91], [4_35, 2_79, 4_60, 2_91], [4_74, 2_79, 5_74, 2_92], [5_87, 2_78, 6_64, 2_91], [6_76, 2_78, 7_38, 2_91], [7_51, 2_79, 8_34, 2_91], [3_72, 2_98, 4_34, 3_10], [3_35, 3_41, 4_83, 3_54], [4_97, 3_41, 6_55, 3_54], [6_67, 3_41, 7_28, 3_54], [7_40, 3_41, 8_25, 3_54], [3_35, 3_60, 4_30, 3_72], [4_42, 3_60, 5_34, 3_72], [5_45, 3_59, 6_87, 3_72], [6_97, 3_60, 7_54, 3_72], [7_65, 3_60, 8_23, 3_73], [3_34, 3_78, 4_28, 3_91], [4_40, 3_78, 5_77, 3_94], [5_90, 3_78, 7_05, 3_91], [7_20, 3_78, 8_01, 3_91], [3_34, 3_97, 4_00, 4_09], [3_70, 4_16, 5_29, 4_29], [5_44, 4_16, 5_76, 4_32], [5_87, 4_16, 6_65, 4_28], [6_77, 4_16, 8_14, 4_29], [3_72, 4_35, 4_52, 4_50], [4_65, 4_34, 4_95, 4_47], [5_11, 4_34, 6_00, 4_47], [6_11, 4_36, 6_37, 4_47], [6_49, 4_36, 6_94, 4_51], [7_05, 4_38, 8_24, 4_47], [3_69, 4_53, 4_52, 4_66], [4_64, 4_54, 5_09, 4_66], [5_22, 4_53, 6_11, 4_69], [6_25, 4_53, 7_92, 4_69], [3_70, 4_72, 5_56, 4_88], [5_70, 4_72, 6_84, 4_87], [6_97, 4_72, 7_18, 4_85], [7_32, 4_72, 8_35, 4_88], [3_69, 4_90, 4_11, 5_03], [4_25, 4_90, 4_84, 5_03], [4_96, 4_90, 6_35, 5_06], [6_45, 4_90, 7_07, 5_03], [7_18, 4_91, 7_61, 5_03], [7_71, 4_90, 8_40, 5_03], [3_36, 5_10, 3_74, 5_21], [3_88, 5_10, 4_47, 5_22], [4_60, 5_10, 4_89, 5_21], [5_03, 5_10, 5_80, 5_22], [5_92, 5_09, 7_36, 5_25], [7_45, 5_09, 7_70, 5_22], [7_81, 5_09, 8_40, 5_22], [3_38, 5_28, 4_34, 5_41], [4_48, 5_28, 5_96, 5_41], [6_09, 5_27, 6_87, 5_40], [7_00, 5_28, 7_92, 5_41], [3_36, 5_46, 3_97, 5_59], [4_07, 5_46, 4_31, 5_59], [4_43, 5_46, 5_25, 5_60], [5_37, 5_46, 6_80, 5_62], [6_88, 5_46, 7_14, 5_59], [7_22, 5_46, 8_37, 5_62], [3_36, 5_65, 4_49, 5_81], [4_61, 5_65, 4_85, 5_77], [4_97, 5_65, 6_65, 5_81], [6_81, 5_65, 7_18, 5_77], [7_32, 5_65, 8_37, 5_80], [3_37, 5_84, 4_38, 5_97], [4_52, 5_83, 5_21, 5_96], [5_35, 5_84, 6_77, 5_99], [6_90, 5_83, 7_87, 5_96], [8_01, 5_83, 8_25, 5_96], [3_38, 6_02, 4_78, 6_15], [4_92, 6_02, 5_30, 6_14], [5_43, 6_02, 6_38, 6_15], [6_50, 6_02, 6_76, 6_14], [6_88, 6_02, 7_88, 6_15], [8_02, 6_02, 8_43, 6_14], [3_37, 6_21, 5_02, 6_33], [5_16, 6_21, 6_15, 6_37], [6_29, 6_21, 7_74, 6_36], [7_89, 6_21, 8_27, 6_33], [3_37, 6_39, 4_18, 6_52], [4_32, 6_40, 5_71, 6_53], [5_87, 6_39, 7_31, 6_55], [7_43, 6_39, 7_69, 6_52], [7_80, 6_39, 8_41, 6_52], [3_38, 6_58, 4_40, 6_73], [4_55, 6_58, 4_91, 6_70], [5_08, 6_58, 6_02, 6_71], [6_16, 6_58, 6_38, 6_70], [6_54, 6_58, 8_35, 6_74], [3_37, 6_77, 4_29, 6_89], [3_37, 7_14, 4_82, 7_26], [4_95, 7_14, 5_48, 7_26], [5_61, 7_14, 6_83, 7_26], [3_38, 7_70, 4_61, 7_82], [4_74, 7_69, 5_54, 7_85], [4_89, 7_88, 5_62, 8_03], [5_76, 7_88, 6_43, 8_01], [6_56, 7_87, 7_51, 8_04], [7_64, 7_88, 8_44, 8_01], [3_34, 8_25, 4_21, 8_38], [4_30, 8_24, 5_74, 8_38], [5_84, 8_24, 7_23, 8_41], [3_35, 8_44, 4_50, 8_57], [4_64, 8_43, 5_83, 8_60], [6_28, 8_62, 7_55, 8_75], [7_69, 8_61, 8_48, 8_78]]]  # noqa: E231
           # fmt: on

           self.assertListEqual(encoding.words					,      __a     )
           self.assertListEqual(encoding.boxes					,      __a     )

           # with apply_OCR = False
           lowerCamelCase             =		LayoutLMvaImageProcessor(apply_ocr=__a     )

           lowerCamelCase             =		image_processing(__a					,      return_tensors="pt"     )

           self.assertEqual(encoding.pixel_values.shape					,      (1, 3, 2_24, 2_24)     )