




import argparse
import json
import pickle
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig
from transformers.utils import logging


logging.set_verbosity_info()
lowerCamelCase__ :   Tuple					=							logging.get_logger(__name__)

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	str							)					-> Tuple:
      SCREAMING_SNAKE_CASE_							=			SwinConfig.from_pretrained(
          'microsoft/swin-tiny-patch4-window7-224'			,			out_features=['stage1', 'stage2', 'stage3', 'stage4']							)
      SCREAMING_SNAKE_CASE_							=			MaskFormerConfig(backbone_config=__UpperCAmelCase							)

      SCREAMING_SNAKE_CASE_							=			'huggingface/label-files'
      if "ade20k-full" in model_name:
            # this should be ok
            SCREAMING_SNAKE_CASE_							=			8_47
            SCREAMING_SNAKE_CASE_							=			'maskformer-ade20k-full-id2label.json'
      elif "ade" in model_name:
            # this should be ok
            SCREAMING_SNAKE_CASE_							=			1_50
            SCREAMING_SNAKE_CASE_							=			'ade20k-id2label.json'
      elif "coco-stuff" in model_name:
            # this should be ok
            SCREAMING_SNAKE_CASE_							=			1_71
            SCREAMING_SNAKE_CASE_							=			'maskformer-coco-stuff-id2label.json'
      elif "coco" in model_name:
            # TODO
            SCREAMING_SNAKE_CASE_							=			1_33
            SCREAMING_SNAKE_CASE_							=			'coco-panoptic-id2label.json'
      elif "cityscapes" in model_name:
            # this should be ok
            SCREAMING_SNAKE_CASE_							=			19
            SCREAMING_SNAKE_CASE_							=			'cityscapes-id2label.json'
      elif "vistas" in model_name:
            # this should be ok
            SCREAMING_SNAKE_CASE_							=			65
            SCREAMING_SNAKE_CASE_							=			'mapillary-vistas-id2label.json'

      SCREAMING_SNAKE_CASE_							=			json.load(open(hf_hub_download(__UpperCAmelCase			,			__UpperCAmelCase			,			repo_type='dataset'							)			,			'r'							)							)
      SCREAMING_SNAKE_CASE_							=			{int(__UpperCAmelCase							): v for k, v in idalabel.items()}

      return config

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	int							)					-> Tuple:
      SCREAMING_SNAKE_CASE_							=			[]
      # stem
      # fmt: off
      rename_keys.append(('backbone.patch_embed.proj.weight', 'model.pixel_level_module.encoder.model.embeddings.patch_embeddings.projection.weight')							)
      rename_keys.append(('backbone.patch_embed.proj.bias', 'model.pixel_level_module.encoder.model.embeddings.patch_embeddings.projection.bias')							)
      rename_keys.append(('backbone.patch_embed.norm.weight', 'model.pixel_level_module.encoder.model.embeddings.norm.weight')							)
      rename_keys.append(('backbone.patch_embed.norm.bias', 'model.pixel_level_module.encoder.model.embeddings.norm.bias')							)
      # stages
      for i in range(len(config.backbone_config.depths							)							):
            for j in range(config.backbone_config.depths[i]							):
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.norm1.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.layernorm_before.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.norm1.bias", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.layernorm_before.bias")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.attn.relative_position_bias_table", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.attention.self.relative_position_bias_table")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.attn.relative_position_index", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.attention.self.relative_position_index")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.attn.proj.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.attention.output.dense.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.attn.proj.bias", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.attention.output.dense.bias")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.norm2.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.layernorm_after.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.norm2.bias", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.layernorm_after.bias")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.mlp.fc1.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.intermediate.dense.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.mlp.fc1.bias", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.intermediate.dense.bias")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.mlp.fc2.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.output.dense.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.blocks.{j}.mlp.fc2.bias", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.blocks.{j}.output.dense.bias")							)

            if i < 3:
                  rename_keys.append((f"backbone.layers.{i}.downsample.reduction.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.downsample.reduction.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.downsample.norm.weight", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.downsample.norm.weight")							)
                  rename_keys.append((f"backbone.layers.{i}.downsample.norm.bias", f"model.pixel_level_module.encoder.model.encoder.layers.{i}.downsample.norm.bias")							)
            rename_keys.append((f"backbone.norm{i}.weight", f"model.pixel_level_module.encoder.hidden_states_norms.{i}.weight")							)
            rename_keys.append((f"backbone.norm{i}.bias", f"model.pixel_level_module.encoder.hidden_states_norms.{i}.bias")							)

      # FPN
      rename_keys.append(('sem_seg_head.layer_4.weight', 'model.pixel_level_module.decoder.fpn.stem.0.weight')							)
      rename_keys.append(('sem_seg_head.layer_4.norm.weight', 'model.pixel_level_module.decoder.fpn.stem.1.weight')							)
      rename_keys.append(('sem_seg_head.layer_4.norm.bias', 'model.pixel_level_module.decoder.fpn.stem.1.bias')							)
      for source_index, target_index in zip(range(3			,			0			,			-1							)			,			range(0			,			3							)							):
            rename_keys.append((f"sem_seg_head.adapter_{source_index}.weight", f"model.pixel_level_module.decoder.fpn.layers.{target_index}.proj.0.weight")							)
            rename_keys.append((f"sem_seg_head.adapter_{source_index}.norm.weight", f"model.pixel_level_module.decoder.fpn.layers.{target_index}.proj.1.weight")							)
            rename_keys.append((f"sem_seg_head.adapter_{source_index}.norm.bias", f"model.pixel_level_module.decoder.fpn.layers.{target_index}.proj.1.bias")							)
            rename_keys.append((f"sem_seg_head.layer_{source_index}.weight", f"model.pixel_level_module.decoder.fpn.layers.{target_index}.block.0.weight")							)
            rename_keys.append((f"sem_seg_head.layer_{source_index}.norm.weight", f"model.pixel_level_module.decoder.fpn.layers.{target_index}.block.1.weight")							)
            rename_keys.append((f"sem_seg_head.layer_{source_index}.norm.bias", f"model.pixel_level_module.decoder.fpn.layers.{target_index}.block.1.bias")							)
      rename_keys.append(('sem_seg_head.mask_features.weight', 'model.pixel_level_module.decoder.mask_projection.weight')							)
      rename_keys.append(('sem_seg_head.mask_features.bias', 'model.pixel_level_module.decoder.mask_projection.bias')							)

      # Transformer decoder
      for idx in range(config.decoder_config.decoder_layers							):
            # self-attention out projection
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.self_attn.out_proj.weight", f"model.transformer_module.decoder.layers.{idx}.self_attn.out_proj.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.self_attn.out_proj.bias", f"model.transformer_module.decoder.layers.{idx}.self_attn.out_proj.bias")							)
            # cross-attention out projection
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.multihead_attn.out_proj.weight", f"model.transformer_module.decoder.layers.{idx}.encoder_attn.out_proj.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.multihead_attn.out_proj.bias", f"model.transformer_module.decoder.layers.{idx}.encoder_attn.out_proj.bias")							)
            # MLP 1
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.linear1.weight", f"model.transformer_module.decoder.layers.{idx}.fc1.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.linear1.bias", f"model.transformer_module.decoder.layers.{idx}.fc1.bias")							)
            # MLP 2
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.linear2.weight", f"model.transformer_module.decoder.layers.{idx}.fc2.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.linear2.bias", f"model.transformer_module.decoder.layers.{idx}.fc2.bias")							)
            # layernorm 1 (self-attention layernorm)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.norm1.weight", f"model.transformer_module.decoder.layers.{idx}.self_attn_layer_norm.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.norm1.bias", f"model.transformer_module.decoder.layers.{idx}.self_attn_layer_norm.bias")							)
            # layernorm 2 (cross-attention layernorm)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.norm2.weight", f"model.transformer_module.decoder.layers.{idx}.encoder_attn_layer_norm.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.norm2.bias", f"model.transformer_module.decoder.layers.{idx}.encoder_attn_layer_norm.bias")							)
            # layernorm 3 (final layernorm)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.norm3.weight", f"model.transformer_module.decoder.layers.{idx}.final_layer_norm.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.norm3.bias", f"model.transformer_module.decoder.layers.{idx}.final_layer_norm.bias")							)

      rename_keys.append(('sem_seg_head.predictor.transformer.decoder.norm.weight', 'model.transformer_module.decoder.layernorm.weight')							)
      rename_keys.append(('sem_seg_head.predictor.transformer.decoder.norm.bias', 'model.transformer_module.decoder.layernorm.bias')							)

      # heads on top
      rename_keys.append(('sem_seg_head.predictor.query_embed.weight', 'model.transformer_module.queries_embedder.weight')							)

      rename_keys.append(('sem_seg_head.predictor.input_proj.weight', 'model.transformer_module.input_projection.weight')							)
      rename_keys.append(('sem_seg_head.predictor.input_proj.bias', 'model.transformer_module.input_projection.bias')							)

      rename_keys.append(('sem_seg_head.predictor.class_embed.weight', 'class_predictor.weight')							)
      rename_keys.append(('sem_seg_head.predictor.class_embed.bias', 'class_predictor.bias')							)

      for i in range(3							):
            rename_keys.append((f"sem_seg_head.predictor.mask_embed.layers.{i}.weight", f"mask_embedder.{i}.0.weight")							)
            rename_keys.append((f"sem_seg_head.predictor.mask_embed.layers.{i}.bias", f"mask_embedder.{i}.0.bias")							)
      # fmt: on

      return rename_keys

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Tuple			,			__UpperCAmelCase						:	Optional[int]			,			__UpperCAmelCase						:	Optional[Any]							)					-> List[str]:
      SCREAMING_SNAKE_CASE_							=			dct.pop(__UpperCAmelCase							)
      SCREAMING_SNAKE_CASE_							=			val

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[str]			,			__UpperCAmelCase						:	Any							)					-> List[str]:
      SCREAMING_SNAKE_CASE_							=			[int(backbone_config.embed_dim * 2**i							) for i in range(len(backbone_config.depths							)							)]
      for i in range(len(backbone_config.depths							)							):
            SCREAMING_SNAKE_CASE_							=			num_features[i]
            for j in range(backbone_config.depths[i]							):
                  # fmt: off
                  # read in weights + bias of input projection layer (in original implementation, this is a single matrix + bias)
                  SCREAMING_SNAKE_CASE_							=			state_dict.pop(f"backbone.layers.{i}.blocks.{j}.attn.qkv.weight"							)
                  SCREAMING_SNAKE_CASE_							=			state_dict.pop(f"backbone.layers.{i}.blocks.{j}.attn.qkv.bias"							)
                  # next, add query, keys and values (in that order) to the state dict
                  SCREAMING_SNAKE_CASE_							=			in_proj_weight[:dim, :]
                  SCREAMING_SNAKE_CASE_							=			in_proj_bias[: dim]
                  SCREAMING_SNAKE_CASE_							=			in_proj_weight[
                      dim : dim * 2, :
                  ]
                  SCREAMING_SNAKE_CASE_							=			in_proj_bias[
                      dim : dim * 2
                  ]
                  SCREAMING_SNAKE_CASE_							=			in_proj_weight[
                      -dim :, :
                  ]
                  SCREAMING_SNAKE_CASE_							=			in_proj_bias[-dim :]
                  # fmt: on

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[str]			,			__UpperCAmelCase						:	List[Any]							)					-> int:
      # fmt: off
      SCREAMING_SNAKE_CASE_							=			config.decoder_config.hidden_size
      for idx in range(config.decoder_config.decoder_layers							):
            # read in weights + bias of self-attention input projection layer (in the original implementation, this is a single matrix + bias)
            SCREAMING_SNAKE_CASE_							=			state_dict.pop(f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.self_attn.in_proj_weight"							)
            SCREAMING_SNAKE_CASE_							=			state_dict.pop(f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.self_attn.in_proj_bias"							)
            # next, add query, keys and values (in that order) to the state dict
            SCREAMING_SNAKE_CASE_							=			in_proj_weight[: hidden_size, :]
            SCREAMING_SNAKE_CASE_							=			in_proj_bias[:config.hidden_size]
            SCREAMING_SNAKE_CASE_							=			in_proj_weight[hidden_size : hidden_size * 2, :]
            SCREAMING_SNAKE_CASE_							=			in_proj_bias[hidden_size : hidden_size * 2]
            SCREAMING_SNAKE_CASE_							=			in_proj_weight[-hidden_size :, :]
            SCREAMING_SNAKE_CASE_							=			in_proj_bias[-hidden_size :]
            # read in weights + bias of cross-attention input projection layer (in the original implementation, this is a single matrix + bias)
            SCREAMING_SNAKE_CASE_							=			state_dict.pop(f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.multihead_attn.in_proj_weight"							)
            SCREAMING_SNAKE_CASE_							=			state_dict.pop(f"sem_seg_head.predictor.transformer.decoder.layers.{idx}.multihead_attn.in_proj_bias"							)
            # next, add query, keys and values (in that order) to the state dict
            SCREAMING_SNAKE_CASE_							=			in_proj_weight[: hidden_size, :]
            SCREAMING_SNAKE_CASE_							=			in_proj_bias[:config.hidden_size]
            SCREAMING_SNAKE_CASE_							=			in_proj_weight[hidden_size : hidden_size * 2, :]
            SCREAMING_SNAKE_CASE_							=			in_proj_bias[hidden_size : hidden_size * 2]
            SCREAMING_SNAKE_CASE_							=			in_proj_weight[-hidden_size :, :]
            SCREAMING_SNAKE_CASE_							=			in_proj_bias[-hidden_size :]
      # fmt: on

def 					UpperCAmelCase_							(      )					-> torch.Tensor:
      SCREAMING_SNAKE_CASE_							=			'http://images.cocodataset.org/val2017/000000039769.jpg'
      SCREAMING_SNAKE_CASE_							=			Image.open(requests.get(__UpperCAmelCase			,			stream=__UpperCAmelCase							).raw							)
      return im

@torch.no_grad()
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	str			,			__UpperCAmelCase						:	str			,			__UpperCAmelCase						:	str			,			__UpperCAmelCase						:	bool = False							)					-> Dict:
      SCREAMING_SNAKE_CASE_							=			get_maskformer_config(__UpperCAmelCase							)

      # load original state_dict
      with open(__UpperCAmelCase			,			'rb'							) as f:
            SCREAMING_SNAKE_CASE_							=			pickle.load(__UpperCAmelCase							)
      SCREAMING_SNAKE_CASE_							=			data['model']

      # for name, param in state_dict.items():
      #     print(name, param.shape)

      # rename keys
      SCREAMING_SNAKE_CASE_							=			create_rename_keys(__UpperCAmelCase							)
      for src, dest in rename_keys:
            rename_key(__UpperCAmelCase			,			__UpperCAmelCase			,			__UpperCAmelCase							)
      read_in_swin_q_k_v(__UpperCAmelCase			,			config.backbone_config							)
      read_in_decoder_q_k_v(__UpperCAmelCase			,			__UpperCAmelCase							)

      # update to torch tensors
      for key, value in state_dict.items():
            SCREAMING_SNAKE_CASE_							=			torch.from_numpy(__UpperCAmelCase							)

      # load 🤗 model
      SCREAMING_SNAKE_CASE_							=			MaskFormerForInstanceSegmentation(__UpperCAmelCase							)
      model.eval()

      for name, param in model.named_parameters():
            print(__UpperCAmelCase			,			param.shape							)

      SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			model.load_state_dict(__UpperCAmelCase			,			strict=__UpperCAmelCase							)
      assert missing_keys == [
          "model.pixel_level_module.encoder.model.layernorm.weight",
          "model.pixel_level_module.encoder.model.layernorm.bias",
      ]
      assert len(__UpperCAmelCase							) == 0, f"Unexpected keys: {unexpected_keys}"

      # verify results
      SCREAMING_SNAKE_CASE_							=			prepare_img()
      if "vistas" in model_name:
            SCREAMING_SNAKE_CASE_							=			65
      elif "cityscapes" in model_name:
            SCREAMING_SNAKE_CASE_							=			6_55_35
      else:
            SCREAMING_SNAKE_CASE_							=			2_55
      SCREAMING_SNAKE_CASE_							=			True if 'ade' in model_name else False
      SCREAMING_SNAKE_CASE_							=			MaskFormerImageProcessor(ignore_index=__UpperCAmelCase			,			reduce_labels=__UpperCAmelCase							)

      SCREAMING_SNAKE_CASE_							=			image_processor(__UpperCAmelCase			,			return_tensors='pt'							)

      SCREAMING_SNAKE_CASE_							=			model(**__UpperCAmelCase							)

      print('Logits:'			,			outputs.class_queries_logits[0, :3, :3]							)

      if model_name == "maskformer-swin-tiny-ade":
            SCREAMING_SNAKE_CASE_							=			torch.tensor(
                [[3.6_3_5_3, -4.4_7_7_0, -2.6_0_6_5], [0.5_0_8_1, -4.2_3_9_4, -3.5_3_4_3], [2.1_9_0_9, -5.0_3_5_3, -1.9_3_2_3]]							)
      assert torch.allclose(outputs.class_queries_logits[0, :3, :3]			,			__UpperCAmelCase			,			atol=1E-4							)
      print('Looks ok!'							)

      if pytorch_dump_folder_path is not None:
            print(f"Saving model and image processor to {pytorch_dump_folder_path}"							)
            Path(__UpperCAmelCase							).mkdir(exist_ok=__UpperCAmelCase							)
            model.save_pretrained(__UpperCAmelCase							)
            image_processor.save_pretrained(__UpperCAmelCase							)

      if push_to_hub:
            print('Pushing model and image processor to the hub...'							)
            model.push_to_hub(f"nielsr/{model_name}"							)
            image_processor.push_to_hub(f"nielsr/{model_name}"							)


if __name__ == "__main__":
   lowerCamelCase__ :   int					=							argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       '--model_name',
       default='maskformer-swin-tiny-ade',
       type=str,
       help=('Name of the MaskFormer model you\'d like to convert',),
   )
   parser.add_argument(
       '--checkpoint_path',
       default='/Users/nielsrogge/Documents/MaskFormer_checkpoints/MaskFormer-Swin-tiny-ADE20k/model.pkl',
       type=str,
       help='Path to the original state dict (.pth file).',
   )
   parser.add_argument(
       '--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model directory.'
   )
   parser.add_argument(
       '--push_to_hub', action='store_true', help='Whether or not to push the converted model to the 🤗 hub.'
   )

   lowerCamelCase__ :   Optional[int]					=							parser.parse_args()
   convert_maskformer_checkpoint(
       args.model_name, args.checkpoint_path, args.pytorch_dump_folder_path, args.push_to_hub
   )





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 					UpperCAmelCase_							(      )					-> str:
      SCREAMING_SNAKE_CASE_							=			10
      SCREAMING_SNAKE_CASE_							=			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'							),
          }							)
      SCREAMING_SNAKE_CASE_							=			datasets.Dataset.from_dict(
          {
              'tokens': [['foo'] * 5] * n,
              'labels': [[1] * 5] * n,
              'answers': [{'answer_start': [97], 'text': ['1976']}] * 10,
              'id': list(range(__UpperCAmelCase							)							),
          }			,			features=__UpperCAmelCase			,			)
      return dataset

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Tuple			,			__UpperCAmelCase						:	str							)					-> int:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'file.arrow'							)
      dataset.map(cache_file_name=__UpperCAmelCase							)
      return filename


# FILE_CONTENT + files


lowerCamelCase__ :   List[Any]					=							'\\n    Text data.\n    Second line of data.'

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Any							)					-> List[str]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'file.txt'
      SCREAMING_SNAKE_CASE_							=			FILE_CONTENT
      with open(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase							)
      return filename

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict							)					-> List[str]:
      import bza

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[Any]							)					-> Any:
      import gzip

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[str]							)					-> int:
      if datasets.config.LZ4_AVAILABLE:
            import lza.frame

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[Any]			,			__UpperCAmelCase						:	Union[str, Any]							)					-> Any:
      if datasets.config.PY7ZR_AVAILABLE:
            import pyazr

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict			,			__UpperCAmelCase						:	str							)					-> str:
      import tarfile

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	str							)					-> List[Any]:
      import lzma

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict			,			__UpperCAmelCase						:	Dict							)					-> str:
      import zipfile

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict							)					-> Any:
      if datasets.config.ZSTANDARD_AVAILABLE:
            import zstandard as zstd

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	int							)					-> List[Any]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'file.xml'
      SCREAMING_SNAKE_CASE_							=			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(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase							)
      return filename


lowerCamelCase__ :   Optional[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},
]
lowerCamelCase__ :   Dict					=							[
    {'col_1': '4', 'col_2': 4, 'col_3': 4.0},
    {'col_1': '5', 'col_2': 5, 'col_3': 5.0},
]
lowerCamelCase__ :   Optional[int]					=							{
    'col_1': ['0', '1', '2', '3'],
    'col_2': [0, 1, 2, 3],
    'col_3': [0.0, 1.0, 2.0, 3.0],
}

lowerCamelCase__ :   List[Any]					=							[
    {'col_3': 0.0, 'col_1': '0', 'col_2': 0},
    {'col_3': 1.0, 'col_1': '1', 'col_2': 1},
]

lowerCamelCase__ :   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 					UpperCAmelCase_							(      )					-> Tuple:
      return DATA_DICT_OF_LISTS

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[Any]							)					-> Union[str, Any]:
      SCREAMING_SNAKE_CASE_							=			datasets.Dataset.from_dict(__UpperCAmelCase							)
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.arrow'							)
      dataset.map(cache_file_name=__UpperCAmelCase							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[str]							)					-> List[str]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.sqlite'							)
      with contextlib.closing(sqlitea.connect(__UpperCAmelCase							)							) as con:
            SCREAMING_SNAKE_CASE_							=			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 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[int]							)					-> str:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.csv'							)
      with open(__UpperCAmelCase			,			'w'			,			newline=''							) as f:
            SCREAMING_SNAKE_CASE_							=			csv.DictWriter(__UpperCAmelCase			,			fieldnames=['col_1', 'col_2', 'col_3']							)
            writer.writeheader()
            for item in DATA:
                  writer.writerow(__UpperCAmelCase							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Tuple							)					-> Optional[Any]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset2.csv'							)
      with open(__UpperCAmelCase			,			'w'			,			newline=''							) as f:
            SCREAMING_SNAKE_CASE_							=			csv.DictWriter(__UpperCAmelCase			,			fieldnames=['col_1', 'col_2', 'col_3']							)
            writer.writeheader()
            for item in DATA:
                  writer.writerow(__UpperCAmelCase							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	str			,			__UpperCAmelCase						:	Tuple							)					-> str:
      import bza

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict			,			__UpperCAmelCase						:	List[str]			,			__UpperCAmelCase						:	str							)					-> Optional[int]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.csv.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[Any]			,			__UpperCAmelCase						:	int			,			__UpperCAmelCase						:	str							)					-> Any:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.csv.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(csv_path.replace('.csv'			,			'.CSV'							)							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(csva_path.replace('.csv'			,			'.CSV'							)							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	int			,			__UpperCAmelCase						:	Tuple			,			__UpperCAmelCase						:	List[Any]							)					-> Union[str, Any]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset_with_dir.csv.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.join('main_dir'			,			os.path.basename(__UpperCAmelCase							)							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.join('main_dir'			,			os.path.basename(__UpperCAmelCase							)							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[str]							)					-> Optional[Any]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.parquet'							)
      SCREAMING_SNAKE_CASE_							=			pa.schema(
          {
              'col_1': pa.string(),
              'col_2': pa.intaa(),
              'col_3': pa.floataa(),
          }							)
      with open(__UpperCAmelCase			,			'wb'							) as f:
            SCREAMING_SNAKE_CASE_							=			pq.ParquetWriter(__UpperCAmelCase			,			schema=__UpperCAmelCase							)
            SCREAMING_SNAKE_CASE_							=			pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(__UpperCAmelCase							)							)] for k in DATA[0]}			,			schema=__UpperCAmelCase							)
            writer.write_table(__UpperCAmelCase							)
            writer.close()
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Tuple							)					-> Any:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.json'							)
      SCREAMING_SNAKE_CASE_							=			{'data': DATA}
      with open(__UpperCAmelCase			,			'w'							) as f:
            json.dump(__UpperCAmelCase			,			__UpperCAmelCase							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Union[str, Any]							)					-> Optional[Any]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.json'							)
      SCREAMING_SNAKE_CASE_							=			{'data': DATA_DICT_OF_LISTS}
      with open(__UpperCAmelCase			,			'w'							) as f:
            json.dump(__UpperCAmelCase			,			__UpperCAmelCase							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict							)					-> List[str]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.jsonl'							)
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in DATA:
                  f.write(json.dumps(__UpperCAmelCase							) + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[Any]							)					-> Optional[Any]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset2.jsonl'							)
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in DATA:
                  f.write(json.dumps(__UpperCAmelCase							) + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[Any]							)					-> List[Any]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset_312.jsonl'							)
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in DATA_312:
                  f.write(json.dumps(__UpperCAmelCase							) + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[Any]							)					-> List[Any]:
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset-str.jsonl'							)
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in DATA_STR:
                  f.write(json.dumps(__UpperCAmelCase							) + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Union[str, Any]			,			__UpperCAmelCase						:	List[str]							)					-> Union[str, Any]:
      import gzip

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	str			,			__UpperCAmelCase						:	Optional[Any]							)					-> List[str]:
      import gzip

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

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Union[str, Any]			,			__UpperCAmelCase						:	Optional[Any]			,			__UpperCAmelCase						:	Dict							)					-> Optional[int]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.jsonl.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[Any]			,			__UpperCAmelCase						:	Any			,			__UpperCAmelCase						:	List[str]			,			__UpperCAmelCase						:	List[str]							)					-> Optional[int]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset_nested.jsonl.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.join('nested'			,			os.path.basename(__UpperCAmelCase							)							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[str]			,			__UpperCAmelCase						:	Optional[Any]			,			__UpperCAmelCase						:	str							)					-> Any:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset_with_dir.jsonl.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.join('main_dir'			,			os.path.basename(__UpperCAmelCase							)							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.join('main_dir'			,			os.path.basename(__UpperCAmelCase							)							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[Any]			,			__UpperCAmelCase						:	List[Any]			,			__UpperCAmelCase						:	Tuple							)					-> Dict:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.jsonl.tar'
      with tarfile.TarFile(__UpperCAmelCase			,			'w'							) as f:
            f.add(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
            f.add(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[int]			,			__UpperCAmelCase						:	Optional[int]			,			__UpperCAmelCase						:	Optional[Any]			,			__UpperCAmelCase						:	List[Any]							)					-> List[str]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset_nested.jsonl.tar'
      with tarfile.TarFile(__UpperCAmelCase			,			'w'							) as f:
            f.add(__UpperCAmelCase			,			arcname=os.path.join('nested'			,			os.path.basename(__UpperCAmelCase							)							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[Any]							)					-> Optional[Any]:
      SCREAMING_SNAKE_CASE_							=			['0', '1', '2', '3']
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset.txt'							)
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in data:
                  f.write(item + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict							)					-> Any:
      SCREAMING_SNAKE_CASE_							=			['0', '1', '2', '3']
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset2.txt'							)
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in data:
                  f.write(item + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	List[Any]							)					-> int:
      SCREAMING_SNAKE_CASE_							=			['0', '1', '2', '3']
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.abc'
      with open(__UpperCAmelCase			,			'w'							) as f:
            for item in data:
                  f.write(item + '\n'							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Any			,			__UpperCAmelCase						:	Dict			,			__UpperCAmelCase						:	Dict							)					-> Union[str, Any]:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.text.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Tuple			,			__UpperCAmelCase						:	int			,			__UpperCAmelCase						:	Optional[int]							)					-> Any:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset_with_dir.text.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.join('main_dir'			,			os.path.basename(__UpperCAmelCase							)							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.join('main_dir'			,			os.path.basename(__UpperCAmelCase							)							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Union[str, Any]			,			__UpperCAmelCase						:	Any			,			__UpperCAmelCase						:	Union[str, Any]							)					-> Dict:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.ext.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.basename('unsupported.ext'							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.basename('unsupported_2.ext'							)							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Union[str, Any]							)					-> Dict:
      SCREAMING_SNAKE_CASE_							=			'\n'.join(['First', 'Second\u2029with Unicode new line', 'Third']							)
      SCREAMING_SNAKE_CASE_							=			str(tmp_path_factory.mktemp('data'							) / 'dataset_with_unicode_new_lines.txt'							)
      with open(__UpperCAmelCase			,			'w'			,			encoding='utf-8'							) as f:
            f.write(__UpperCAmelCase							)
      return path

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      )					-> List[Any]:
      return os.path.join('tests'			,			'features'			,			'data'			,			'test_image_rgb.jpg'							)

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      )					-> Tuple:
      return os.path.join('tests'			,			'features'			,			'data'			,			'test_audio_44100.wav'							)

@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Dict			,			__UpperCAmelCase						:	Dict							)					-> int:
      SCREAMING_SNAKE_CASE_							=			tmp_path_factory.mktemp('data'							) / 'dataset.img.zip'
      with zipfile.ZipFile(__UpperCAmelCase			,			'w'							) as f:
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							)							)
            f.write(__UpperCAmelCase			,			arcname=os.path.basename(__UpperCAmelCase							).replace('.jpg'			,			'2.jpg'							)							)
      return path





@pytest.fixture(scope='session'							)
def 					UpperCAmelCase_							(      __UpperCAmelCase						:	str							)					-> Dict:
      SCREAMING_SNAKE_CASE_							=			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