from typing import Optional, Union

import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_mobilenet_va import MobileNetVaConfig


SCREAMING_SNAKE_CASE			:						Dict				  =		logging.get_logger(__name__)


# General docstring
SCREAMING_SNAKE_CASE			:						Optional[int]				  =		"""MobileNetV1Config"""

# Base docstring
SCREAMING_SNAKE_CASE			:						Any				  =		"""google/mobilenet_v1_1.0_224"""
SCREAMING_SNAKE_CASE			:						Any				  =		[1, 1024, 7, 7]

# Image classification docstring
SCREAMING_SNAKE_CASE			:						Tuple				  =		"""google/mobilenet_v1_1.0_224"""
SCREAMING_SNAKE_CASE			:						int				  =		"""tabby, tabby cat"""


SCREAMING_SNAKE_CASE			:						Optional[int]				  =		[
    """google/mobilenet_v1_1.0_224""",
    """google/mobilenet_v1_0.75_192""",
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
]



def 	__A		(      _A				,					_A				,					_A=None       ):



 """simple docstring"""


 __a							=	{}

 if isinstance(_A				,					_A       ):
  __a							=	model.mobilenet_va
 else:
  __a							=	model

 __a							=	"MobilenetV1/Conv2d_0/"
 __a							=	backbone.conv_stem.convolution.weight
 __a							=	backbone.conv_stem.normalization.bias
 __a							=	backbone.conv_stem.normalization.weight
 __a							=	backbone.conv_stem.normalization.running_mean
 __a							=	backbone.conv_stem.normalization.running_var

 for i in range(13       ):
  __a							=	i + 1
  __a							=	i * 2

  __a							=	backbone.layer[pt_index]
  __a							=	f"""MobilenetV1/Conv2d_{tf_index}_depthwise/"""
  __a							=	pointer.convolution.weight
  __a							=	pointer.normalization.bias
  __a							=	pointer.normalization.weight
  __a							=	pointer.normalization.running_mean
  __a							=	pointer.normalization.running_var

  __a							=	backbone.layer[pt_index + 1]
  __a							=	f"""MobilenetV1/Conv2d_{tf_index}_pointwise/"""
  __a							=	pointer.convolution.weight
  __a							=	pointer.normalization.bias
  __a							=	pointer.normalization.weight
  __a							=	pointer.normalization.running_mean
  __a							=	pointer.normalization.running_var

 if isinstance(_A				,					_A       ):
  __a							=	"MobilenetV1/Logits/Conv2d_1c_1x1/"
  __a							=	model.classifier.weight
  __a							=	model.classifier.bias

 return tf_to_pt_map



def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 try:
  import numpy as np
  import tensorflow as tf
 except ImportError:
  logger.error(
      "Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see "
      "https://www.tensorflow.org/install/ for installation instructions."       )
  raise

 # Load weights from TF model
 __a							=	tf.train.list_variables(_A       )
 __a							=	{}
 for name, shape in init_vars:
  logger.info(f"""Loading TF weight {name} with shape {shape}"""       )
  __a							=	tf.train.load_variable(_A				,					_A       )
  __a							=	array

 # Build TF to PyTorch weights loading map
 __a							=	_build_tf_to_pytorch_map(_A				,					_A				,					_A       )

 for name, pointer in tf_to_pt_map.items():
  logger.info(f"""Importing {name}"""       )
  if name not in tf_weights:
   logger.info(f"""{name} not in tf pre-trained weights, skipping"""       )
   continue

  __a							=	tf_weights[name]

  if "depthwise_weights" in name:
   logger.info("Transposing depthwise"       )
   __a							=	np.transpose(_A				,					(2, 3, 0, 1)       )
  elif "weights" in name:
   logger.info("Transposing"       )
   if len(pointer.shape       ) == 2:  # copying into linear layer
    __a							=	array.squeeze().transpose()
   else:
    __a							=	np.transpose(_A				,					(3, 2, 0, 1)       )

  if pointer.shape != array.shape:
   raise ValueError(f"""Pointer shape {pointer.shape} and array shape {array.shape} mismatched"""       )

  logger.info(f"""Initialize PyTorch weight {name} {array.shape}"""       )
  __a							=	torch.from_numpy(_A       )

  tf_weights.pop(_A				,					_A       )
  tf_weights.pop(name + "/RMSProp"				,					_A       )
  tf_weights.pop(name + "/RMSProp_1"				,					_A       )
  tf_weights.pop(name + "/ExponentialMovingAverage"				,					_A       )

 logger.info(f"""Weights not copied to PyTorch model: {", ".join(tf_weights.keys()       )}"""       )
 return model



def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 __a							,  __a							=	features.shape[-2:]
 __a							,  __a							=	conv_layer.stride
 __a							,  __a							=	conv_layer.kernel_size

 if in_height % stride_height == 0:
  __a							=	max(kernel_height - stride_height				,					0       )
 else:
  __a							=	max(kernel_height - (in_height % stride_height)				,					0       )

 if in_width % stride_width == 0:
  __a							=	max(kernel_width - stride_width				,					0       )
 else:
  __a							=	max(kernel_width - (in_width % stride_width)				,					0       )

 __a							=	pad_along_width // 2
 __a							=	pad_along_width - pad_left
 __a							=	pad_along_height // 2
 __a							=	pad_along_height - pad_top

 __a							=	(pad_left, pad_right, pad_top, pad_bottom)
 return nn.functional.pad(_A				,					_A				,					"constant"				,					0.0       )
class  A_			(							nn.Module			):

  def __init__(		self			:   Tuple  ,				__SCREAMING_SNAKE_CASE			:   MobileNetVaConfig  ,				__SCREAMING_SNAKE_CASE			:   int  ,				__SCREAMING_SNAKE_CASE			:   int  ,				__SCREAMING_SNAKE_CASE			:   int  ,				__SCREAMING_SNAKE_CASE			:   Optional[int] = 1  ,				__SCREAMING_SNAKE_CASE			:   Optional[int] = 1  ,				__SCREAMING_SNAKE_CASE			:   bool = False  ,				__SCREAMING_SNAKE_CASE			:   Optional[bool] = True  ,				__SCREAMING_SNAKE_CASE			:   Optional[bool or str] = True  ,				):
   super().__init__()
   __a							=	config

   if in_channels % groups != 0:
    raise ValueError(f"""Input channels ({in_channels}) are not divisible by {groups} groups."""							)
   if out_channels % groups != 0:
    raise ValueError(f"""Output channels ({out_channels}) are not divisible by {groups} groups."""							)

   __a							=	0 if config.tf_padding else int((kernel_size - 1) / 2							)

   __a							=	nn.Convad(
       in_channels=__SCREAMING_SNAKE_CASE  ,				out_channels=__SCREAMING_SNAKE_CASE  ,				kernel_size=__SCREAMING_SNAKE_CASE  ,				stride=__SCREAMING_SNAKE_CASE  ,				padding=__SCREAMING_SNAKE_CASE  ,				groups=__SCREAMING_SNAKE_CASE  ,				bias=__SCREAMING_SNAKE_CASE  ,				padding_mode="zeros"  ,				)

   if use_normalization:
    __a							=	nn.BatchNormad(
        num_features=__SCREAMING_SNAKE_CASE  ,				eps=config.layer_norm_eps  ,				momentum=0.99_97  ,				affine=__SCREAMING_SNAKE_CASE  ,				track_running_stats=__SCREAMING_SNAKE_CASE  ,				)
   else:
    __a							=	None

   if use_activation:
    if isinstance(__SCREAMING_SNAKE_CASE  ,				__SCREAMING_SNAKE_CASE							):
     __a							=	ACTaFN[use_activation]
    elif isinstance(config.hidden_act  ,				__SCREAMING_SNAKE_CASE							):
     __a							=	ACTaFN[config.hidden_act]
    else:
     __a							=	config.hidden_act
   else:
    __a							=	None

  def 		_UpperCAmelCase (		self			:   int  ,				__SCREAMING_SNAKE_CASE			:   torch.Tensor							):
   if self.config.tf_padding:
    __a							=	apply_tf_padding(__SCREAMING_SNAKE_CASE  ,				self.convolution							)
   __a							=	self.convolution(__SCREAMING_SNAKE_CASE							)
   if self.normalization is not None:
    __a							=	self.normalization(__SCREAMING_SNAKE_CASE							)
   if self.activation is not None:
    __a							=	self.activation(__SCREAMING_SNAKE_CASE							)
   return features
class  A_			(							a_			):
  _SCREAMING_SNAKE_CASE     					=      MobileNetVaConfig
  _SCREAMING_SNAKE_CASE     					=      load_tf_weights_in_mobilenet_va
  _SCREAMING_SNAKE_CASE     					=      """mobilenet_v1"""
  _SCREAMING_SNAKE_CASE     					=      """pixel_values"""
  _SCREAMING_SNAKE_CASE     					=      False

  def 		_UpperCAmelCase (		self			:   Tuple  ,				__SCREAMING_SNAKE_CASE			:   Union[nn.Linear, nn.Convad]							):
   if isinstance(__SCREAMING_SNAKE_CASE  ,				(nn.Linear, nn.Convad)							):
    module.weight.data.normal_(mean=0.0  ,				std=self.config.initializer_range							)
    if module.bias is not None:
     module.bias.data.zero_()
   elif isinstance(__SCREAMING_SNAKE_CASE  ,				nn.BatchNormad							):
    module.bias.data.zero_()
    module.weight.data.fill_(1.0							)
SCREAMING_SNAKE_CASE			:						Dict				  =		R"""
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it
    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`MobileNetV1Config`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
"""

SCREAMING_SNAKE_CASE			:						Optional[int]				  =		R"""
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`MobileNetV1ImageProcessor.__call__`] for details.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
"""
@add_start_docstrings(
    """The bare MobileNetV1 model outputting raw hidden-states without any specific head on top."""      ,							a_      ,							)
class  A_			(							a_			):

  def __init__(		self			:   Optional[Any]  ,				__SCREAMING_SNAKE_CASE			:   MobileNetVaConfig  ,				__SCREAMING_SNAKE_CASE			:   bool = True							):
   super().__init__(__SCREAMING_SNAKE_CASE							)
   __a							=	config

   __a							=	32
   __a							=	max(int(depth * config.depth_multiplier							)  ,				config.min_depth							)

   __a							=	MobileNetVaConvLayer(
       __SCREAMING_SNAKE_CASE  ,				in_channels=config.num_channels  ,				out_channels=__SCREAMING_SNAKE_CASE  ,				kernel_size=3  ,				stride=2  ,				)

   __a							=	[1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1]

   __a							=	nn.ModuleList()
   for i in range(13							):
    __a							=	out_channels

    if strides[i] == 2 or i == 0:
     depth *= 2
     __a							=	max(int(depth * config.depth_multiplier							)  ,				config.min_depth							)

    self.layer.append(
        MobileNetVaConvLayer(
            __SCREAMING_SNAKE_CASE  ,				in_channels=__SCREAMING_SNAKE_CASE  ,				out_channels=__SCREAMING_SNAKE_CASE  ,				kernel_size=3  ,				stride=strides[i]  ,				groups=__SCREAMING_SNAKE_CASE  ,				)							)

    self.layer.append(
        MobileNetVaConvLayer(
            __SCREAMING_SNAKE_CASE  ,				in_channels=__SCREAMING_SNAKE_CASE  ,				out_channels=__SCREAMING_SNAKE_CASE  ,				kernel_size=1  ,				)							)

   __a							=	nn.AdaptiveAvgPoolad((1, 1)							) if add_pooling_layer else None

   # Initialize weights and apply final processing
   self.post_init()

  def 		_UpperCAmelCase (		self			:   Any  ,				__SCREAMING_SNAKE_CASE			:   int							):
   raise NotImplementedError

  @add_start_docstrings_to_model_forward(__SCREAMING_SNAKE_CASE							)
  @add_code_sample_docstrings(
      checkpoint=_CHECKPOINT_FOR_DOC  ,				output_type=__SCREAMING_SNAKE_CASE  ,				config_class=_CONFIG_FOR_DOC  ,				modality="vision"  ,				expected_output=_EXPECTED_OUTPUT_SHAPE  ,				)
  def 		_UpperCAmelCase (		self			:   List[str]  ,				__SCREAMING_SNAKE_CASE			:   Optional[torch.Tensor] = None  ,				__SCREAMING_SNAKE_CASE			:   Optional[bool] = None  ,				__SCREAMING_SNAKE_CASE			:   Optional[bool] = None  ,				):
   __a							=	(
       output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
   )
   __a							=	return_dict if return_dict is not None else self.config.use_return_dict

   if pixel_values is None:
    raise ValueError("You have to specify pixel_values"							)

   __a							=	self.conv_stem(__SCREAMING_SNAKE_CASE							)

   __a							=	() if output_hidden_states else None

   for i, layer_module in enumerate(self.layer							):
    __a							=	layer_module(__SCREAMING_SNAKE_CASE							)

    if output_hidden_states:
     __a							=	all_hidden_states + (hidden_states,)

   __a							=	hidden_states

   if self.pooler is not None:
    __a							=	torch.flatten(self.pooler(__SCREAMING_SNAKE_CASE							)  ,				start_dim=1							)
   else:
    __a							=	None

   if not return_dict:
    return tuple(v for v in [last_hidden_state, pooled_output, all_hidden_states] if v is not None							)

   return BaseModelOutputWithPoolingAndNoAttention(
       last_hidden_state=__SCREAMING_SNAKE_CASE  ,				pooler_output=__SCREAMING_SNAKE_CASE  ,				hidden_states=__SCREAMING_SNAKE_CASE  ,				)
@add_start_docstrings(
    """
    MobileNetV1 model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    """      ,							a_      ,							)
class  A_			(							a_			):

  def __init__(		self			:   int  ,				__SCREAMING_SNAKE_CASE			:   MobileNetVaConfig							):
   super().__init__(__SCREAMING_SNAKE_CASE							)

   __a							=	config.num_labels
   __a							=	MobileNetVaModel(__SCREAMING_SNAKE_CASE							)

   __a							=	self.mobilenet_va.layer[-1].convolution.out_channels

   # Classifier head
   __a							=	nn.Dropout(config.classifier_dropout_prob  ,				inplace=__SCREAMING_SNAKE_CASE							)
   __a							=	nn.Linear(__SCREAMING_SNAKE_CASE  ,				config.num_labels							) if config.num_labels > 0 else nn.Identity()

   # Initialize weights and apply final processing
   self.post_init()

  @add_start_docstrings_to_model_forward(__SCREAMING_SNAKE_CASE							)
  @add_code_sample_docstrings(
      checkpoint=_IMAGE_CLASS_CHECKPOINT  ,				output_type=__SCREAMING_SNAKE_CASE  ,				config_class=_CONFIG_FOR_DOC  ,				expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT  ,				)
  def 		_UpperCAmelCase (		self			:   Any  ,				__SCREAMING_SNAKE_CASE			:   Optional[torch.Tensor] = None  ,				__SCREAMING_SNAKE_CASE			:   Optional[bool] = None  ,				__SCREAMING_SNAKE_CASE			:   Optional[torch.Tensor] = None  ,				__SCREAMING_SNAKE_CASE			:   Optional[bool] = None  ,				):
   __a							=	return_dict if return_dict is not None else self.config.use_return_dict

   __a							=	self.mobilenet_va(__SCREAMING_SNAKE_CASE  ,				output_hidden_states=__SCREAMING_SNAKE_CASE  ,				return_dict=__SCREAMING_SNAKE_CASE							)

   __a							=	outputs.pooler_output if return_dict else outputs[1]

   __a							=	self.classifier(self.dropout(__SCREAMING_SNAKE_CASE							)							)

   __a							=	None
   if labels is not None:
    if self.config.problem_type is None:
     if self.num_labels == 1:
      __a							=	"regression"
     elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
      __a							=	"single_label_classification"
     else:
      __a							=	"multi_label_classification"

    if self.config.problem_type == "regression":
     __a							=	MSELoss()
     if self.num_labels == 1:
      __a							=	loss_fct(logits.squeeze()  ,				labels.squeeze()							)
     else:
      __a							=	loss_fct(__SCREAMING_SNAKE_CASE  ,				__SCREAMING_SNAKE_CASE							)
    elif self.config.problem_type == "single_label_classification":
     __a							=	CrossEntropyLoss()
     __a							=	loss_fct(logits.view(-1  ,				self.num_labels							)  ,				labels.view(-1							)							)
    elif self.config.problem_type == "multi_label_classification":
     __a							=	BCEWithLogitsLoss()
     __a							=	loss_fct(__SCREAMING_SNAKE_CASE  ,				__SCREAMING_SNAKE_CASE							)

   if not return_dict:
    __a							=	(logits,) + outputs[2:]
    return ((loss,) + output) if loss is not None else output

   return ImageClassifierOutputWithNoAttention(
       loss=__SCREAMING_SNAKE_CASE  ,				logits=__SCREAMING_SNAKE_CASE  ,				hidden_states=outputs.hidden_states  ,				)



import contextlib
import csv
import json
import os
import sqlitea
import tarfile
import textwrap
import zipfile

import pyarrow as pa
import pyarrow.parquet as pq
import pytest

import datasets
import datasets.config



@pytest.fixture(scope="session"       )
def 	__A		(      ):



 """simple docstring"""


 __a							=	10
 __a							=	datasets.Features(
     {
         "tokens": datasets.Sequence(datasets.Value("string"       )       ),
         "labels": datasets.Sequence(datasets.ClassLabel(names=["negative", "positive"]       )       ),
         "answers": datasets.Sequence(
             {
                 "text": datasets.Value("string"       ),
                 "answer_start": datasets.Value("int32"       ),
             }       ),
         "id": datasets.Value("int64"       ),
     }       )
 __a							=	datasets.Dataset.from_dict(
     {
         "tokens": [["foo"] * 5] * n,
         "labels": [[1] * 5] * n,
         "answers": [{"answer_start": [97], "text": ["1976"]}] * 10,
         "id": list(range(_A       )       ),
     }				,					features=_A				,					)
 return dataset



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "file.arrow"       )
 dataset.map(cache_file_name=_A       )
 return filename


# FILE_CONTENT + files


SCREAMING_SNAKE_CASE			:						Tuple				  =		"""\
    Text data.
    Second line of data."""



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt"
 __a							=	FILE_CONTENT
 with open(_A				,					"w"       ) as f:
  f.write(_A       )
 return filename



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 import bza

 __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.bz2"
 __a							=	bytes(_A				,					"utf-8"       )
 with bza.open(_A				,					"wb"       ) as f:
  f.write(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 import gzip

 __a							=	str(tmp_path_factory.mktemp("data"       ) / "file.txt.gz"       )
 __a							=	bytes(_A				,					"utf-8"       )
 with gzip.open(_A				,					"wb"       ) as f:
  f.write(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 if datasets.config.LZ4_AVAILABLE:
  import lza.frame

  __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.lz4"
  __a							=	bytes(_A				,					"utf-8"       )
  with lza.frame.open(_A				,					"wb"       ) as f:
   f.write(_A       )
  return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 if datasets.config.PY7ZR_AVAILABLE:
  import pyazr

  __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.7z"
  with pyazr.SevenZipFile(_A				,					"w"       ) as archive:
   archive.write(_A				,					arcname=os.path.basename(_A       )       )
  return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 import tarfile

 __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.tar"
 with tarfile.TarFile(_A				,					"w"       ) as f:
  f.add(_A				,					arcname=os.path.basename(_A       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 import lzma

 __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.xz"
 __a							=	bytes(_A				,					"utf-8"       )
 with lzma.open(_A				,					"wb"       ) as f:
  f.write(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 import zipfile

 __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename(_A       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 if datasets.config.ZSTANDARD_AVAILABLE:
  import zstandard as zstd

  __a							=	tmp_path_factory.mktemp("data"       ) / "file.txt.zst"
  __a							=	bytes(_A				,					"utf-8"       )
  with zstd.open(_A				,					"wb"       ) as f:
   f.write(_A       )
  return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "file.xml"
 __a							=	textwrap.dedent(
     "\\n    <?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n    <tmx version=\"1.4\">\n      <header segtype=\"sentence\" srclang=\"ca\" />\n      <body>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 1</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 1</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 2</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 2</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 3</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 3</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 4</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 4</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 5</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 5</seg></tuv>\n        </tu>\n      </body>\n    </tmx>"       )
 with open(_A				,					"w"       ) as f:
  f.write(_A       )
 return filename


SCREAMING_SNAKE_CASE			:						Any				  =		[
    {"""col_1""": """0""", """col_2""": 0, """col_3""": 0.0},
    {"""col_1""": """1""", """col_2""": 1, """col_3""": 1.0},
    {"""col_1""": """2""", """col_2""": 2, """col_3""": 2.0},
    {"""col_1""": """3""", """col_2""": 3, """col_3""": 3.0},
]
SCREAMING_SNAKE_CASE			:						Optional[int]				  =		[
    {"""col_1""": """4""", """col_2""": 4, """col_3""": 4.0},
    {"""col_1""": """5""", """col_2""": 5, """col_3""": 5.0},
]
SCREAMING_SNAKE_CASE			:						Any				  =		{
    """col_1""": ["""0""", """1""", """2""", """3"""],
    """col_2""": [0, 1, 2, 3],
    """col_3""": [0.0, 1.0, 2.0, 3.0],
}

SCREAMING_SNAKE_CASE			:						int				  =		[
    {"""col_3""": 0.0, """col_1""": """0""", """col_2""": 0},
    {"""col_3""": 1.0, """col_1""": """1""", """col_2""": 1},
]

SCREAMING_SNAKE_CASE			:						List[Any]				  =		[
    {"""col_1""": """s0""", """col_2""": 0, """col_3""": 0.0},
    {"""col_1""": """s1""", """col_2""": 1, """col_3""": 1.0},
    {"""col_1""": """s2""", """col_2""": 2, """col_3""": 2.0},
    {"""col_1""": """s3""", """col_2""": 3, """col_3""": 3.0},
]



@pytest.fixture(scope="session"       )
def 	__A		(      ):



 """simple docstring"""


 return DATA_DICT_OF_LISTS



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	datasets.Dataset.from_dict(_A       )
 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.arrow"       )
 dataset.map(cache_file_name=_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.sqlite"       )
 with contextlib.closing(sqlitea.connect(_A       )       ) as con:
  __a							=	con.cursor()
  cur.execute("CREATE TABLE dataset(col_1 text, col_2 int, col_3 real)"       )
  for item in DATA:
   cur.execute("INSERT INTO dataset(col_1, col_2, col_3) VALUES (?, ?, ?)"				,					tuple(item.values()       )       )
  con.commit()
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.csv"       )
 with open(_A				,					"w"				,					newline=""       ) as f:
  __a							=	csv.DictWriter(_A				,					fieldnames=["col_1", "col_2", "col_3"]       )
  writer.writeheader()
  for item in DATA:
   writer.writerow(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset2.csv"       )
 with open(_A				,					"w"				,					newline=""       ) as f:
  __a							=	csv.DictWriter(_A				,					fieldnames=["col_1", "col_2", "col_3"]       )
  writer.writeheader()
  for item in DATA:
   writer.writerow(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 import bza

 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.csv.bz2"
 with open(_A				,					"rb"       ) as f:
  __a							=	f.read()
 # data = bytes(FILE_CONTENT, "utf-8")
 with bza.open(_A				,					"wb"       ) as f:
  f.write(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.csv.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename(_A       )       )
  f.write(_A				,					arcname=os.path.basename(_A       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.csv.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename(csv_path.replace(".csv"				,					".CSV"       )       )       )
  f.write(_A				,					arcname=os.path.basename(csva_path.replace(".csv"				,					".CSV"       )       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset_with_dir.csv.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.join("main_dir"				,					os.path.basename(_A       )       )       )
  f.write(_A				,					arcname=os.path.join("main_dir"				,					os.path.basename(_A       )       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.parquet"       )
 __a							=	pa.schema(
     {
         "col_1": pa.string(),
         "col_2": pa.intaa(),
         "col_3": pa.floataa(),
     }       )
 with open(_A				,					"wb"       ) as f:
  __a							=	pq.ParquetWriter(_A				,					schema=_A       )
  __a							=	pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(_A       )       )] for k in DATA[0]}				,					schema=_A       )
  writer.write_table(_A       )
  writer.close()
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.json"       )
 __a							=	{"data": DATA}
 with open(_A				,					"w"       ) as f:
  json.dump(_A				,					_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.json"       )
 __a							=	{"data": DATA_DICT_OF_LISTS}
 with open(_A				,					"w"       ) as f:
  json.dump(_A				,					_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.jsonl"       )
 with open(_A				,					"w"       ) as f:
  for item in DATA:
   f.write(json.dumps(_A       ) + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset2.jsonl"       )
 with open(_A				,					"w"       ) as f:
  for item in DATA:
   f.write(json.dumps(_A       ) + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset_312.jsonl"       )
 with open(_A				,					"w"       ) as f:
  for item in DATA_312:
   f.write(json.dumps(_A       ) + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset-str.jsonl"       )
 with open(_A				,					"w"       ) as f:
  for item in DATA_STR:
   f.write(json.dumps(_A       ) + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 import gzip

 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.txt.gz"       )
 with open(_A				,					"rb"       ) as orig_file:
  with gzip.open(_A				,					"wb"       ) as zipped_file:
   zipped_file.writelines(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 import gzip

 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.jsonl.gz"       )
 with open(_A				,					"rb"       ) as orig_file:
  with gzip.open(_A				,					"wb"       ) as zipped_file:
   zipped_file.writelines(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.jsonl.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename(_A       )       )
  f.write(_A				,					arcname=os.path.basename(_A       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset_nested.jsonl.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.join("nested"				,					os.path.basename(_A       )       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset_with_dir.jsonl.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.join("main_dir"				,					os.path.basename(_A       )       )       )
  f.write(_A				,					arcname=os.path.join("main_dir"				,					os.path.basename(_A       )       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.jsonl.tar"
 with tarfile.TarFile(_A				,					"w"       ) as f:
  f.add(_A				,					arcname=os.path.basename(_A       )       )
  f.add(_A				,					arcname=os.path.basename(_A       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset_nested.jsonl.tar"
 with tarfile.TarFile(_A				,					"w"       ) as f:
  f.add(_A				,					arcname=os.path.join("nested"				,					os.path.basename(_A       )       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	["0", "1", "2", "3"]
 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset.txt"       )
 with open(_A				,					"w"       ) as f:
  for item in data:
   f.write(item + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	["0", "1", "2", "3"]
 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset2.txt"       )
 with open(_A				,					"w"       ) as f:
  for item in data:
   f.write(item + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	["0", "1", "2", "3"]
 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.abc"
 with open(_A				,					"w"       ) as f:
  for item in data:
   f.write(item + "\n"       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.text.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename(_A       )       )
  f.write(_A				,					arcname=os.path.basename(_A       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset_with_dir.text.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.join("main_dir"				,					os.path.basename(_A       )       )       )
  f.write(_A				,					arcname=os.path.join("main_dir"				,					os.path.basename(_A       )       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.ext.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename("unsupported.ext"       )       )
  f.write(_A				,					arcname=os.path.basename("unsupported_2.ext"       )       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	"\n".join(["First", "Second\u2029with Unicode new line", "Third"]       )
 __a							=	str(tmp_path_factory.mktemp("data"       ) / "dataset_with_unicode_new_lines.txt"       )
 with open(_A				,					"w"				,					encoding="utf-8"       ) as f:
  f.write(_A       )
 return path



@pytest.fixture(scope="session"       )
def 	__A		(      ):



 """simple docstring"""


 return os.path.join("tests"				,					"features"				,					"data"				,					"test_image_rgb.jpg"       )



@pytest.fixture(scope="session"       )
def 	__A		(      ):



 """simple docstring"""


 return os.path.join("tests"				,					"features"				,					"data"				,					"test_audio_44100.wav"       )



@pytest.fixture(scope="session"       )
def 	__A		(      _A				,					_A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data"       ) / "dataset.img.zip"
 with zipfile.ZipFile(_A				,					"w"       ) as f:
  f.write(_A				,					arcname=os.path.basename(_A       )       )
  f.write(_A				,					arcname=os.path.basename(_A       ).replace(".jpg"				,					"2.jpg"       )       )
 return path






@pytest.fixture(scope="session"       )
def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	tmp_path_factory.mktemp("data_dir"       )

 (data_dir / "subdir").mkdir()
 with open(data_dir / "subdir" / "train.txt"				,					"w"       ) as f:
  f.write("foo\n" * 10       )
 with open(data_dir / "subdir" / "test.txt"				,					"w"       ) as f:
  f.write("bar\n" * 10       )
 # hidden file
 with open(data_dir / "subdir" / ".test.txt"				,					"w"       ) as f:
  f.write("bar\n" * 10       )

 # hidden directory
 (data_dir / ".subdir").mkdir()
 with open(data_dir / ".subdir" / "train.txt"				,					"w"       ) as f:
  f.write("foo\n" * 10       )
 with open(data_dir / ".subdir" / "test.txt"				,					"w"       ) as f:
  f.write("bar\n" * 10       )

 return data_dir


