
import unittest

from transformers import EsmConfig, is_torch_available
from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers.models.esm.modeling_esmfold import EsmForProteinFolding





class  snake_case     :

							def __init__(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_=13       ,       SCREAMING_SNAKE_CASE_=7       ,       SCREAMING_SNAKE_CASE_=False       ,       SCREAMING_SNAKE_CASE_=True       ,       SCREAMING_SNAKE_CASE_=False       ,       SCREAMING_SNAKE_CASE_=False       ,       SCREAMING_SNAKE_CASE_=19       ,       SCREAMING_SNAKE_CASE_=32       ,       SCREAMING_SNAKE_CASE_=5       ,       SCREAMING_SNAKE_CASE_=4       ,       SCREAMING_SNAKE_CASE_=37       ,       SCREAMING_SNAKE_CASE_="gelu"       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=5_12       ,       SCREAMING_SNAKE_CASE_=16       ,       SCREAMING_SNAKE_CASE_=2       ,       SCREAMING_SNAKE_CASE_=0.02       ,       SCREAMING_SNAKE_CASE_=3       ,       SCREAMING_SNAKE_CASE_=4       ,       SCREAMING_SNAKE_CASE_=None       ,       ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = parent
									SCREAMING_SNAKE_CASE_						 = batch_size
									SCREAMING_SNAKE_CASE_						 = seq_length
									SCREAMING_SNAKE_CASE_						 = is_training
									SCREAMING_SNAKE_CASE_						 = use_input_mask
									SCREAMING_SNAKE_CASE_						 = use_token_type_ids
									SCREAMING_SNAKE_CASE_						 = use_labels
									SCREAMING_SNAKE_CASE_						 = vocab_size
									SCREAMING_SNAKE_CASE_						 = hidden_size
									SCREAMING_SNAKE_CASE_						 = num_hidden_layers
									SCREAMING_SNAKE_CASE_						 = num_attention_heads
									SCREAMING_SNAKE_CASE_						 = intermediate_size
									SCREAMING_SNAKE_CASE_						 = hidden_act
									SCREAMING_SNAKE_CASE_						 = hidden_dropout_prob
									SCREAMING_SNAKE_CASE_						 = attention_probs_dropout_prob
									SCREAMING_SNAKE_CASE_						 = max_position_embeddings
									SCREAMING_SNAKE_CASE_						 = type_vocab_size
									SCREAMING_SNAKE_CASE_						 = type_sequence_label_size
									SCREAMING_SNAKE_CASE_						 = initializer_range
									SCREAMING_SNAKE_CASE_						 = num_labels
									SCREAMING_SNAKE_CASE_						 = num_choices
									SCREAMING_SNAKE_CASE_						 = scope

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size, self.seq_length]       ,       self.vocab_size    )

									SCREAMING_SNAKE_CASE_						 = None
									if self.use_input_mask:
											SCREAMING_SNAKE_CASE_						 = random_attention_mask([self.batch_size, self.seq_length]    )

									SCREAMING_SNAKE_CASE_						 = None
									SCREAMING_SNAKE_CASE_						 = None
									SCREAMING_SNAKE_CASE_						 = None
									if self.use_labels:
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size]       ,       self.type_sequence_label_size    )
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size, self.seq_length]       ,       self.num_labels    )
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size]       ,       self.num_choices    )

									SCREAMING_SNAKE_CASE_						 = self.get_config()

									return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = EsmConfig(
									    vocab_size=33       ,       hidden_size=self.hidden_size       ,       pad_token_id=1       ,       num_hidden_layers=self.num_hidden_layers       ,       num_attention_heads=self.num_attention_heads       ,       intermediate_size=self.intermediate_size       ,       hidden_act=self.hidden_act       ,       hidden_dropout_prob=self.hidden_dropout_prob       ,       attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,       max_position_embeddings=self.max_position_embeddings       ,       type_vocab_size=self.type_vocab_size       ,       initializer_range=self.initializer_range       ,       is_folding_model=SCREAMING_SNAKE_CASE_       ,       esmfold_config={'''trunk''': {'''num_blocks''': 2}, '''fp16_esm''': False}       ,       )
									return config

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = EsmForProteinFolding(config=SCREAMING_SNAKE_CASE_    ).float()
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_    )

									self.parent.assertEqual(result.positions.shape       ,       (8, self.batch_size, self.seq_length, 14, 3)    )
									self.parent.assertEqual(result.angles.shape       ,       (8, self.batch_size, self.seq_length, 7, 2)    )







							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.prepare_config_and_inputs()
									(
									    (
									    SCREAMING_SNAKE_CASE_					
									) ,(
									    SCREAMING_SNAKE_CASE_					
									) ,(
									    SCREAMING_SNAKE_CASE_					
									) ,(
									    SCREAMING_SNAKE_CASE_					
									) ,(
									    SCREAMING_SNAKE_CASE_					
									) ,(
									    SCREAMING_SNAKE_CASE_					
									) ,					
									)						 = config_and_inputs
									SCREAMING_SNAKE_CASE_						 = {'''input_ids''': input_ids, '''attention_mask''': input_mask}
									return config, inputs_dict







@require_torch
class  snake_case     (							__lowercase       ,			__lowercase       ,			unittest.TestCase   ):
							UpperCAmelCase__						     =      False

							UpperCAmelCase__						     =      (EsmForProteinFolding,) if is_torch_available() else ()
							UpperCAmelCase__						     =      ()
							UpperCAmelCase__						     =      {} if is_torch_available() else {}
							UpperCAmelCase__						     =      False

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = EsmFoldModelTester(self    )
									SCREAMING_SNAKE_CASE_						 = ConfigTester(self       ,       config_class=SCREAMING_SNAKE_CASE_       ,       hidden_size=37    )

							def _lowercase					(self    ):

									"""simple docstring"""







									self.config_tester.run_common_tests()

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_    )

							@unittest.skip('''Does not support attention outputs'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''Esm does not support embedding resizing'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''Esm does not support embedding resizing'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support passing input embeds!'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support head pruning.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support head pruning.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support head pruning.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support head pruning.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support head pruning.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not output hidden states in the normal way.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMfold does not output hidden states in the normal way.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold only has one output format.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''This test doesn\'t work for ESMFold and doesn\'t test core functionality'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold does not support input chunking.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold doesn\'t respect you and it certainly doesn\'t respect your initialization arguments.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

							@unittest.skip('''ESMFold doesn\'t support data parallel.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass







							@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''    )
							def _lowercase					(self    ):

									"""simple docstring"""







									pass







@require_torch
class  snake_case     (							__lowercase   ):

							@slow
							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = EsmForProteinFolding.from_pretrained('''facebook/esmfold_v1'''    ).float()
									model.eval()
									SCREAMING_SNAKE_CASE_						 = torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]    )
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_    )['''positions''']
									SCREAMING_SNAKE_CASE_						 = torch.tensor([2.58_28, 0.79_93, -10.93_34]       ,       dtype=torch.floataa    )
									self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]       ,       SCREAMING_SNAKE_CASE_       ,       atol=1e-4    )    )

"""simple docstring"""




import time
from dataclasses import dataclass
from multiprocessing import Pool
from unittest import TestCase
from unittest.mock import patch

import multiprocess
import numpy as np
import pytest

from datasets.utils.py_utils import (
    NestedDataStructure,
    asdict,
    iflatmap_unordered,
    map_nested,
    temp_seed,
    temporary_assignment,
    zip_dict,
)

from .utils import require_tf, require_torch



def        _lowerCamelCase ( __a    ):  # picklable for multiprocessing
		return x.sum()



def        _lowerCamelCase ( __a    ):  # picklable for multiprocessing
		return i + 1





@dataclass
class  snake_case     :
							UpperCAmelCase__						     =      42
							UpperCAmelCase__						     =      42







class  snake_case     (							__lowercase   ):

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = {}
									SCREAMING_SNAKE_CASE_						 = []
									SCREAMING_SNAKE_CASE_						 = 1
									SCREAMING_SNAKE_CASE_						 = [1, 2]
									SCREAMING_SNAKE_CASE_						 = {'''a''': 1, '''b''': 2}
									SCREAMING_SNAKE_CASE_						 = {'''a''': [1, 2], '''b''': [3, 4]}
									SCREAMING_SNAKE_CASE_						 = {'''a''': {'''1''': 1}, '''b''': 2}
									SCREAMING_SNAKE_CASE_						 = {'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
									SCREAMING_SNAKE_CASE_						 = {}
									SCREAMING_SNAKE_CASE_						 = []
									SCREAMING_SNAKE_CASE_						 = 2
									SCREAMING_SNAKE_CASE_						 = [2, 3]
									SCREAMING_SNAKE_CASE_						 = {'''a''': 2, '''b''': 3}
									SCREAMING_SNAKE_CASE_						 = {'''a''': [2, 3], '''b''': [4, 5]}
									SCREAMING_SNAKE_CASE_						 = {'''a''': {'''1''': 2}, '''b''': 3}
									SCREAMING_SNAKE_CASE_						 = {'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = 2
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = {'''a''': np.eye(2    ), '''b''': np.zeros(3    ), '''c''': np.ones(2    )}
									SCREAMING_SNAKE_CASE_						 = {'''a''': 2, '''b''': 0, '''c''': 2}
									SCREAMING_SNAKE_CASE_						 = {
									    '''a''': np.eye(2    ).astype(SCREAMING_SNAKE_CASE_    ),
									    '''b''': np.zeros(3    ).astype(SCREAMING_SNAKE_CASE_    ),
									    '''c''': np.ones(2    ).astype(SCREAMING_SNAKE_CASE_    ),
									}
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       map_numpy=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(
									    {k: v.tolist() for k, v in map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       map_numpy=SCREAMING_SNAKE_CASE_    ).items()}       ,       {k: v.tolist() for k, v in expected_map_nested_sna_int.items()}       ,       )
									self.assertEqual(map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       map_numpy=SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )       ,       SCREAMING_SNAKE_CASE_    )
									self.assertEqual(
									    {k: v.tolist() for k, v in map_nested(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       map_numpy=SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    ).items()}       ,       {k: v.tolist() for k, v in expected_map_nested_sna_int.items()}       ,       )
									with self.assertRaises(SCREAMING_SNAKE_CASE_    ):  # can't pickle a local lambda
											map_nested(lambda SCREAMING_SNAKE_CASE_    : x + 1       ,       SCREAMING_SNAKE_CASE_       ,       num_proc=SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = {'''a''': 1, '''b''': 2}
									SCREAMING_SNAKE_CASE_						 = {'''a''': 3, '''b''': 4}
									SCREAMING_SNAKE_CASE_						 = {'''a''': 5, '''b''': 6}
									SCREAMING_SNAKE_CASE_						 = sorted([('''a''', (1, 3, 5)), ('''b''', (2, 4, 6))]    )
									self.assertEqual(sorted(zip_dict(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )    )       ,       SCREAMING_SNAKE_CASE_    )







							def _lowercase					(self    ):

									"""simple docstring"""







									class  snake_case     :
																UpperCAmelCase__						     =      '''bar'''







									SCREAMING_SNAKE_CASE_						 = Foo()
									self.assertEqual(foo.my_attr       ,       '''bar'''    )
									with temporary_assignment(SCREAMING_SNAKE_CASE_       ,       '''my_attr'''       ,       '''BAR'''    ):
											self.assertEqual(foo.my_attr       ,       '''BAR'''    )
									self.assertEqual(foo.my_attr       ,       '''bar'''    )







@pytest.mark.parametrize(
    '''iterable_length, num_proc, expected_num_proc''',							[
        (1, None, 1),
        (1, 1, 1),
        (2, None, 1),
        (2, 1, 1),
        (2, 2, 1),
        (2, 3, 1),
        (3, 2, 1),
        (16, 16, 16),
        (16, 17, 16),
        (17, 16, 16),
    ],							)
def        _lowerCamelCase ( __a,							__a,							__a    ):
		with patch('''datasets.utils.py_utils._single_map_nested'''    ) as mock_single_map_nested, patch(
		    '''datasets.parallel.parallel.Pool'''    ) as mock_multiprocessing_pool:
				SCREAMING_SNAKE_CASE_						 = {F'{i}': i for i in range(__a    )}
				SCREAMING_SNAKE_CASE_						 = map_nested(lambda __a    : x + 10,							__a,							num_proc=__a,							parallel_min_length=16    )
				if expected_num_proc == 1:
						assert mock_single_map_nested.called
						assert not mock_multiprocessing_pool.called
				else:
						assert not mock_single_map_nested.called
						assert mock_multiprocessing_pool.called
						assert mock_multiprocessing_pool.call_args[0][0] == expected_num_proc





class  snake_case     (							__lowercase   ):

							@require_tf
							def _lowercase					(self    ):

									"""simple docstring"""







									import tensorflow as tf
									from tensorflow.keras import layers

									SCREAMING_SNAKE_CASE_						 = layers.Dense(2    )

									def gen_random_output():
											SCREAMING_SNAKE_CASE_						 = tf.random.uniform((1, 3)    )
											return model(SCREAMING_SNAKE_CASE_    ).numpy()

									with temp_seed(42       ,       set_tensorflow=SCREAMING_SNAKE_CASE_    ):
											SCREAMING_SNAKE_CASE_						 = gen_random_output()
									with temp_seed(42       ,       set_tensorflow=SCREAMING_SNAKE_CASE_    ):
											SCREAMING_SNAKE_CASE_						 = gen_random_output()
									SCREAMING_SNAKE_CASE_						 = gen_random_output()

									np.testing.assert_equal(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )
									self.assertGreater(np.abs(outa - outa    ).sum()       ,       0    )

							@require_torch
							def _lowercase					(self    ):

									"""simple docstring"""







									import torch

									def gen_random_output():
											SCREAMING_SNAKE_CASE_						 = torch.nn.Linear(3       ,       2    )
											SCREAMING_SNAKE_CASE_						 = torch.rand(1       ,       3    )
											return model(SCREAMING_SNAKE_CASE_    ).detach().numpy()

									with temp_seed(42       ,       set_pytorch=SCREAMING_SNAKE_CASE_    ):
											SCREAMING_SNAKE_CASE_						 = gen_random_output()
									with temp_seed(42       ,       set_pytorch=SCREAMING_SNAKE_CASE_    ):
											SCREAMING_SNAKE_CASE_						 = gen_random_output()
									SCREAMING_SNAKE_CASE_						 = gen_random_output()

									np.testing.assert_equal(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )
									self.assertGreater(np.abs(outa - outa    ).sum()       ,       0    )







							def _lowercase					(self    ):

									"""simple docstring"""







									def gen_random_output():
											return np.random.rand(1       ,       3    )

									with temp_seed(42    ):
											SCREAMING_SNAKE_CASE_						 = gen_random_output()
									with temp_seed(42    ):
											SCREAMING_SNAKE_CASE_						 = gen_random_output()
									SCREAMING_SNAKE_CASE_						 = gen_random_output()

									np.testing.assert_equal(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    )
									self.assertGreater(np.abs(outa - outa    ).sum()       ,       0    )







@pytest.mark.parametrize('''input_data''',							[{}]    )
def        _lowerCamelCase ( __a    ):
		SCREAMING_SNAKE_CASE_						 = NestedDataStructure(__a    ).data
		assert output_data == input_data



@pytest.mark.parametrize(
    '''data, expected_output''',							[
        ({}, []),
        ([], []),
        ('''foo''', ['''foo''']),
        (['''foo''', '''bar'''], ['''foo''', '''bar''']),
        ([['''foo''', '''bar''']], ['''foo''', '''bar''']),
        ([[['''foo'''], ['''bar''']]], ['''foo''', '''bar''']),
        ([[['''foo'''], '''bar''']], ['''foo''', '''bar''']),
        ({'''a''': 1, '''b''': 2}, [1, 2]),
        ({'''a''': [1, 2], '''b''': [3, 4]}, [1, 2, 3, 4]),
        ({'''a''': [[1, 2]], '''b''': [[3, 4]]}, [1, 2, 3, 4]),
        ({'''a''': [[1, 2]], '''b''': [3, 4]}, [1, 2, 3, 4]),
        ({'''a''': [[[1], [2]]], '''b''': [[[3], [4]]]}, [1, 2, 3, 4]),
        ({'''a''': [[[1], [2]]], '''b''': [[3, 4]]}, [1, 2, 3, 4]),
        ({'''a''': [[[1], [2]]], '''b''': [3, 4]}, [1, 2, 3, 4]),
        ({'''a''': [[[1], [2]]], '''b''': [3, [4]]}, [1, 2, 3, 4]),
        ({'''a''': {'''1''': 1}, '''b''': 2}, [1, 2]),
        ({'''a''': {'''1''': [1]}, '''b''': 2}, [1, 2]),
        ({'''a''': {'''1''': [1]}, '''b''': [2]}, [1, 2]),
    ],							)
def        _lowerCamelCase ( __a,							__a    ):
		SCREAMING_SNAKE_CASE_						 = NestedDataStructure(__a    ).flatten()
		assert output == expected_output



def        _lowerCamelCase ( ):
		SCREAMING_SNAKE_CASE_						 = A(x=1,							y='''foobar'''    )
		SCREAMING_SNAKE_CASE_						 = {'''x''': 1, '''y''': '''foobar'''}
		assert asdict(__a    ) == expected_output

		SCREAMING_SNAKE_CASE_						 = {'''a''': {'''b''': A(x=10,							y='''foo'''    )}, '''c''': [A(x=20,							y='''bar'''    )]}
		SCREAMING_SNAKE_CASE_						 = {'''a''': {'''b''': {'''x''': 10, '''y''': '''foo'''}}, '''c''': [{'''x''': 20, '''y''': '''bar'''}]}
		assert asdict(__a    ) == expected_output

		with pytest.raises(__a    ):
				asdict([1, A(x=10,							y='''foo'''    )]    )



def        _lowerCamelCase ( __a    ):
		return text.split()



def        _lowerCamelCase ( __a    ):
		yield (time.time(), content)
		time.sleep(2    )
		yield (time.time(), content)



def        _lowerCamelCase ( ):
		with Pool(2    ) as pool:
				SCREAMING_SNAKE_CASE_						 = list(iflatmap_unordered(__a,							_split_text,							kwargs_iterable=[{'''text''': '''hello there'''}] * 10    )    )
				assert out.count('''hello'''    ) == 10
				assert out.count('''there'''    ) == 10
				assert len(__a    ) == 20

		# check multiprocess from pathos (uses dill for pickling)
		with multiprocess.Pool(2    ) as pool:
				SCREAMING_SNAKE_CASE_						 = list(iflatmap_unordered(__a,							_split_text,							kwargs_iterable=[{'''text''': '''hello there'''}] * 10    )    )
				assert out.count('''hello'''    ) == 10
				assert out.count('''there'''    ) == 10
				assert len(__a    ) == 20

		# check that we get items as fast as possible
		with Pool(2    ) as pool:
				SCREAMING_SNAKE_CASE_						 = []
				for yield_time, content in iflatmap_unordered(
				    __a,							_aseconds_generator_of_aitems_with_timing,							kwargs_iterable=[{'''content''': '''a'''}, {'''content''': '''b'''}]    ):
						assert yield_time < time.time() + 0.1, "we should each item directly after it was yielded"
						out.append(__a    )
				assert out.count('''a'''    ) == 2
				assert out.count('''b'''    ) == 2
				assert len(__a    ) == 4