



import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Image
from datasets.packaged_modules.text.text import Text

from ..utils import require_pil







@pytest.fixture
def       lowerCamelCase_  (    _a       :						Tuple    ):



    '''simple docstring'''




    UpperCAmelCase_     :       Optional[Any]  		=					tmp_path / """text.txt"""
    UpperCAmelCase_     :       Tuple  		=					textwrap.dedent(
        """\
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
        Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        Second paragraph:
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
        Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        """    )
    with open(_a   ,		"""w"""   ,		encoding="""utf-8"""    ) as f:
        f.write(_a    )
    return str(_a    )







@pytest.fixture
def       lowerCamelCase_  (    _a       :						List[Any]   ,		_a       :						Tuple    ):



    '''simple docstring'''




    UpperCAmelCase_     :       int  		=					tmp_path / """text_with_image.txt"""
    with open(_a   ,		"""w"""   ,		encoding="""utf-8"""    ) as f:
        f.write(_a    )
    return str(_a    )







@pytest.mark.parametrize("""keep_linebreaks"""   ,		[True, False]    )
def       lowerCamelCase_  (    _a       :						List[str]   ,		_a       :						int    ):



    '''simple docstring'''




    with open(_a   ,		encoding="""utf-8"""    ) as f:
        UpperCAmelCase_     :       str  		=					f.read().splitlines(keepends=_a    )
    UpperCAmelCase_     :       str  		=					Text(keep_linebreaks=_a   ,		encoding="""utf-8"""    )
    UpperCAmelCase_     :       Optional[Any]  		=					text._generate_tables([[text_file]]    )
    UpperCAmelCase_     :       Optional[Any]  		=					pa.concat_tables([table for _, table in generator]    ).to_pydict()["""text"""]
    assert generated_content == expected_content







@require_pil
def       lowerCamelCase_  (    _a       :						Any    ):



    '''simple docstring'''




    with open(_a   ,		encoding="""utf-8"""    ) as f:
        UpperCAmelCase_     :       str  		=					f.read().splitlines()[0]
    UpperCAmelCase_     :       Tuple  		=					Text(encoding="""utf-8"""   ,		features=Features({"""image""": Image()}    )    )
    UpperCAmelCase_     :       Dict  		=					text._generate_tables([[text_file_with_image]]    )
    UpperCAmelCase_     :       Optional[int]  		=					pa.concat_tables([table for _, table in generator]    )
    assert pa_table.schema.field("""image"""    ).type == Image()()
    UpperCAmelCase_     :       str  		=					pa_table.to_pydict()["""image"""]
    assert generated_content == [{"path": image_file, "bytes": None}]







@pytest.mark.parametrize("""sample_by"""   ,		["""line""", """paragraph""", """document"""]    )
def       lowerCamelCase_  (    _a       :						Dict   ,		_a       :						str    ):



    '''simple docstring'''




    with open(_a   ,		encoding="""utf-8"""    ) as f:
        UpperCAmelCase_     :       str  		=					f.read()
    if sample_by == "line":
        UpperCAmelCase_     :       Tuple  		=					expected_content.splitlines()
    elif sample_by == "paragraph":
        UpperCAmelCase_     :       str  		=					expected_content.split("""\n\n"""    )
    elif sample_by == "document":
        UpperCAmelCase_     :       List[str]  		=					[expected_content]
    UpperCAmelCase_     :       List[str]  		=					Text(sample_by=_a   ,		encoding="""utf-8"""   ,		chunksize=100    )
    UpperCAmelCase_     :       Tuple  		=					text._generate_tables([[text_file]]    )
    UpperCAmelCase_     :       Optional[int]  		=					pa.concat_tables([table for _, table in generator]    ).to_pydict()["""text"""]
    assert generated_content == expected_content







from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowerCAmelCase 	=      logging.get_logger(__name__)

__lowerCAmelCase 	=      {
    "MCG-NJU/videomae-base": "https://huggingface.co/MCG-NJU/videomae-base/resolve/main/config.json",
}




class 	_UpperCAmelCase						( _lowercase       ):
					__A        = "videomae"




					def __init__(    self     ,   __lowerCAmelCase=224     ,   __lowerCAmelCase=16     ,   __lowerCAmelCase=3     ,   __lowerCAmelCase=16     ,   __lowerCAmelCase=2     ,   __lowerCAmelCase=768     ,   __lowerCAmelCase=12     ,   __lowerCAmelCase=12     ,   __lowerCAmelCase=3_072     ,   __lowerCAmelCase="gelu"     ,   __lowerCAmelCase=0.0     ,   __lowerCAmelCase=0.0     ,   __lowerCAmelCase=0.0_2     ,   __lowerCAmelCase=1E-1_2     ,   __lowerCAmelCase=True     ,   __lowerCAmelCase=True     ,   __lowerCAmelCase=6     ,   __lowerCAmelCase=384     ,   __lowerCAmelCase=4     ,   __lowerCAmelCase=1_536     ,   __lowerCAmelCase=True     ,   **__lowerCAmelCase     ,   )    ->	Any:
							super().__init__(**__lowerCAmelCase							)

							UpperCamelCase__								=						image_size
							UpperCamelCase__								=						patch_size
							UpperCamelCase__								=						num_channels
							UpperCamelCase__								=						num_frames
							UpperCamelCase__								=						tubelet_size

							UpperCamelCase__								=						hidden_size
							UpperCamelCase__								=						num_hidden_layers
							UpperCamelCase__								=						num_attention_heads
							UpperCamelCase__								=						intermediate_size
							UpperCamelCase__								=						hidden_act
							UpperCamelCase__								=						hidden_dropout_prob
							UpperCamelCase__								=						attention_probs_dropout_prob
							UpperCamelCase__								=						initializer_range
							UpperCamelCase__								=						layer_norm_eps
							UpperCamelCase__								=						qkv_bias
							UpperCamelCase__								=						use_mean_pooling

							UpperCamelCase__								=						decoder_num_attention_heads
							UpperCamelCase__								=						decoder_hidden_size
							UpperCamelCase__								=						decoder_num_hidden_layers
							UpperCamelCase__								=						decoder_intermediate_size
							UpperCamelCase__								=						norm_pix_loss





