





'''simple docstring'''



from __future__ import annotations

import copy
import inspect
import unittest

import numpy as np

from transformers import is_tf_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
							import tensorflow as tf

							from transformers import (
							    TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
							    TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
							    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
							    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
							    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
							    LayoutLMvaConfig,
							    TFLayoutLMvaForQuestionAnswering,
							    TFLayoutLMvaForSequenceClassification,
							    TFLayoutLMvaForTokenClassification,
							    TFLayoutLMvaModel,
							)

if is_vision_available():
							from PIL import Image

							from transformers import LayoutLMvaImageProcessor






class 							__lowercase    :







	'''simple docstring'''

	def __init__(self       ,_lowerCamelCase       ,_lowerCamelCase=2       ,_lowerCamelCase=3       ,_lowerCamelCase=4       ,_lowerCamelCase=2       ,_lowerCamelCase=7       ,_lowerCamelCase=True       ,_lowerCamelCase=True       ,_lowerCamelCase=True       ,_lowerCamelCase=True       ,_lowerCamelCase=99       ,_lowerCamelCase=36       ,_lowerCamelCase=2       ,_lowerCamelCase=4       ,_lowerCamelCase=37       ,_lowerCamelCase="gelu"       ,_lowerCamelCase=0.1       ,_lowerCamelCase=0.1       ,_lowerCamelCase=512       ,_lowerCamelCase=16       ,_lowerCamelCase=2       ,_lowerCamelCase=0.0_2       ,_lowerCamelCase=6       ,_lowerCamelCase=6       ,_lowerCamelCase=3       ,_lowerCamelCase=4       ,_lowerCamelCase=None       ,_lowerCamelCase=1000       ,)							->							Optional[Any]:







				'''simple docstring'''





				__lowercase			  =							parent
				__lowercase			  =							batch_size
				__lowercase			  =							num_channels
				__lowercase			  =							image_size
				__lowercase			  =							patch_size
				__lowercase			  =							is_training
				__lowercase			  =							use_input_mask
				__lowercase			  =							use_token_type_ids
				__lowercase			  =							use_labels
				__lowercase			  =							vocab_size
				__lowercase			  =							hidden_size
				__lowercase			  =							num_hidden_layers
				__lowercase			  =							num_attention_heads
				__lowercase			  =							intermediate_size
				__lowercase			  =							hidden_act
				__lowercase			  =							hidden_dropout_prob
				__lowercase			  =							attention_probs_dropout_prob
				__lowercase			  =							max_position_embeddings
				__lowercase			  =							type_vocab_size
				__lowercase			  =							type_sequence_label_size
				__lowercase			  =							initializer_range
				__lowercase			  =							coordinate_size
				__lowercase			  =							shape_size
				__lowercase			  =							num_labels
				__lowercase			  =							num_choices
				__lowercase			  =							scope
				__lowercase			  =							range_bbox

				# LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
				__lowercase			  =							text_seq_length
				__lowercase			  =							(image_size // patch_size) ** 2 + 1
				__lowercase			  =							self.text_seq_length + self.image_seq_length


	def   _UpperCAmelCase       (self	)							->							str:







				'''simple docstring'''





				__lowercase			  =							ids_tensor([self.batch_size, self.text_seq_length]       ,self.vocab_size	)

				__lowercase			  =							ids_tensor([self.batch_size, self.text_seq_length, 4]       ,self.range_bbox	)
				__lowercase			  =							bbox.numpy()
				# Ensure that bbox is legal
				for i in range(bbox.shape[0]	):
							for j in range(bbox.shape[1]	):
										if bbox[i, j, 3] < bbox[i, j, 1]:
													__lowercase			  =							bbox[i, j, 3]
													__lowercase			  =							bbox[i, j, 1]
													__lowercase			  =							tmp_coordinate
										if bbox[i, j, 2] < bbox[i, j, 0]:
													__lowercase			  =							bbox[i, j, 2]
													__lowercase			  =							bbox[i, j, 0]
													__lowercase			  =							tmp_coordinate
				__lowercase			  =							tf.constant(SCREAMING_SNAKE_CASE_	)

				__lowercase			  =							floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]	)

				__lowercase			  =							None
				if self.use_input_mask:
							__lowercase			  =							random_attention_mask([self.batch_size, self.text_seq_length]	)

				__lowercase			  =							None
				if self.use_token_type_ids:
							__lowercase			  =							ids_tensor([self.batch_size, self.text_seq_length]       ,self.type_vocab_size	)

				__lowercase			  =							None
				__lowercase			  =							None
				if self.use_labels:
							__lowercase			  =							ids_tensor([self.batch_size]       ,self.type_sequence_label_size	)
							__lowercase			  =							ids_tensor([self.batch_size, self.text_seq_length]       ,self.num_labels	)

				__lowercase			  =							LayoutLMvaConfig(
				    vocab_size=self.vocab_size       ,hidden_size=self.hidden_size       ,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       ,coordinate_size=self.coordinate_size       ,shape_size=self.shape_size       ,input_size=self.image_size       ,patch_size=self.patch_size       ,)

				return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase	)							->							Tuple:







				'''simple docstring'''





				__lowercase			  =							TFLayoutLMvaModel(config=SCREAMING_SNAKE_CASE_	)

				# text + image
				__lowercase			  =							model(SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_	)
				__lowercase			  =							model(
				    SCREAMING_SNAKE_CASE_       ,bbox=SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,attention_mask=SCREAMING_SNAKE_CASE_       ,token_type_ids=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_       ,)
				__lowercase			  =							model(SCREAMING_SNAKE_CASE_       ,bbox=SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_	)

				self.parent.assertEqual(result.last_hidden_state.shape       ,(self.batch_size, self.seq_length, self.hidden_size)	)

				# text only
				__lowercase			  =							model(SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_	)
				self.parent.assertEqual(
				    result.last_hidden_state.shape       ,(self.batch_size, self.text_seq_length, self.hidden_size)	)

				# image only
				__lowercase			  =							model({'''pixel_values''': pixel_values}       ,training=SCREAMING_SNAKE_CASE_	)
				self.parent.assertEqual(
				    result.last_hidden_state.shape       ,(self.batch_size, self.image_seq_length, self.hidden_size)	)


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase	)							->							List[Any]:







				'''simple docstring'''





				__lowercase			  =							self.num_labels
				__lowercase			  =							TFLayoutLMvaForSequenceClassification(config=SCREAMING_SNAKE_CASE_	)
				__lowercase			  =							model(
				    SCREAMING_SNAKE_CASE_       ,bbox=SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,attention_mask=SCREAMING_SNAKE_CASE_       ,token_type_ids=SCREAMING_SNAKE_CASE_       ,labels=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_       ,)
				self.parent.assertEqual(result.logits.shape       ,(self.batch_size, self.num_labels)	)


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase	)							->							List[str]:







				'''simple docstring'''





				__lowercase			  =							self.num_labels
				__lowercase			  =							TFLayoutLMvaForTokenClassification(config=SCREAMING_SNAKE_CASE_	)
				__lowercase			  =							model(
				    SCREAMING_SNAKE_CASE_       ,bbox=SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,attention_mask=SCREAMING_SNAKE_CASE_       ,token_type_ids=SCREAMING_SNAKE_CASE_       ,labels=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_       ,)
				self.parent.assertEqual(result.logits.shape       ,(self.batch_size, self.text_seq_length, self.num_labels)	)


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase	)							->							Union[str, Any]:







				'''simple docstring'''





				__lowercase			  =							2
				__lowercase			  =							TFLayoutLMvaForQuestionAnswering(config=SCREAMING_SNAKE_CASE_	)
				__lowercase			  =							model(
				    SCREAMING_SNAKE_CASE_       ,bbox=SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,attention_mask=SCREAMING_SNAKE_CASE_       ,token_type_ids=SCREAMING_SNAKE_CASE_       ,start_positions=SCREAMING_SNAKE_CASE_       ,end_positions=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_       ,)
				self.parent.assertEqual(result.start_logits.shape       ,(self.batch_size, self.seq_length)	)
				self.parent.assertEqual(result.end_logits.shape       ,(self.batch_size, self.seq_length)	)


	def   _UpperCAmelCase       (self	)							->							str:







				'''simple docstring'''





				__lowercase			  =							self.prepare_config_and_inputs()
				(__lowercase)			  =							config_and_inputs
				__lowercase			  =							{
				    """input_ids""": input_ids,
				    """bbox""": bbox,
				    """pixel_values""": pixel_values,
				    """token_type_ids""": token_type_ids,
				    """attention_mask""": input_mask,
				}
				return config, inputs_dict






@require_tf
class 							__lowercase    ( _UpperCAmelCase	, _UpperCAmelCase	, unittest.TestCase  ):







	'''simple docstring'''

	a      :			List[Any]     =    (
	    (
	        TFLayoutLMvaModel,
	        TFLayoutLMvaForQuestionAnswering,
	        TFLayoutLMvaForSequenceClassification,
	        TFLayoutLMvaForTokenClassification,
	    )
	    if is_tf_available()
	    else ()
	)
	a      :			Union[str, Any]     =    (
	    {'document-question-answering': TFLayoutLMvaForQuestionAnswering, 'feature-extraction': TFLayoutLMvaModel}
	    if is_tf_available()
	    else {}
	)

	a      :			int     =    False
	a      :			List[str]     =    False
	a      :			int     =    False


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase	)							->							int:







				'''simple docstring'''





				return True


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase       ,_lowerCamelCase=False	)							->							Dict:







				'''simple docstring'''





				__lowercase			  =							copy.deepcopy(SCREAMING_SNAKE_CASE_	)

				if model_class in get_values(SCREAMING_SNAKE_CASE_	):
							__lowercase			  =							{
							    k: tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_       ,1	)       ,(1, self.model_tester.num_choices) + (1,) * (v.ndim - 1)	)
							    if isinstance(SCREAMING_SNAKE_CASE_       ,tf.Tensor	) and v.ndim > 0
							    else v
							    for k, v in inputs_dict.items()
							}

				if return_labels:
							if model_class in get_values(SCREAMING_SNAKE_CASE_	):
										__lowercase			  =							tf.ones(self.model_tester.batch_size       ,dtype=tf.intaa	)
							elif model_class in get_values(SCREAMING_SNAKE_CASE_	):
										__lowercase			  =							tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa	)
										__lowercase			  =							tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa	)
							elif model_class in get_values(SCREAMING_SNAKE_CASE_	):
										__lowercase			  =							tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa	)
							elif model_class in get_values(SCREAMING_SNAKE_CASE_	):
										__lowercase			  =							tf.zeros(
										    (self.model_tester.batch_size, self.model_tester.text_seq_length)       ,dtype=tf.intaa	)

				return inputs_dict


	def   _UpperCAmelCase       (self	)							->							Union[str, Any]:







				'''simple docstring'''





				__lowercase			  =							TFLayoutLMvaModelTester(self	)
				__lowercase			  =							ConfigTester(self       ,config_class=SCREAMING_SNAKE_CASE_       ,hidden_size=37	)


	def   _UpperCAmelCase       (self	)							->							Optional[int]:







				'''simple docstring'''





				self.config_tester.run_common_tests()


	def   _UpperCAmelCase       (self	)							->							Any:







				'''simple docstring'''





				__lowercase			  =							self.model_tester.prepare_config_and_inputs_for_common()
				for model_class in self.all_model_classes:
							__lowercase			  =							model_class(SCREAMING_SNAKE_CASE_	)
							if getattr(SCREAMING_SNAKE_CASE_       ,'''hf_compute_loss'''       ,SCREAMING_SNAKE_CASE_	):
										# The number of elements in the loss should be the same as the number of elements in the label
										__lowercase			  =							self._prepare_for_class(inputs_dict.copy()       ,SCREAMING_SNAKE_CASE_       ,return_labels=SCREAMING_SNAKE_CASE_	)
										__lowercase			  =							prepared_for_class[
										    sorted(prepared_for_class.keys() - inputs_dict.keys()       ,reverse=SCREAMING_SNAKE_CASE_	)[0]
										]
										__lowercase			  =							added_label.shape.as_list()[:1]

										# Test that model correctly compute the loss with kwargs
										__lowercase			  =							self._prepare_for_class(inputs_dict.copy()       ,SCREAMING_SNAKE_CASE_       ,return_labels=SCREAMING_SNAKE_CASE_	)
										__lowercase			  =							prepared_for_class.pop('''input_ids'''	)

										__lowercase			  =							model(SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_	)[0]
										self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]	)

										# Test that model correctly compute the loss when we mask some positions
										__lowercase			  =							self._prepare_for_class(inputs_dict.copy()       ,SCREAMING_SNAKE_CASE_       ,return_labels=SCREAMING_SNAKE_CASE_	)
										__lowercase			  =							prepared_for_class.pop('''input_ids'''	)
										if "labels" in prepared_for_class:
													__lowercase			  =							prepared_for_class["""labels"""].numpy()
													if len(labels.shape	) > 1 and labels.shape[1] != 1:
																__lowercase			  =							-100
																__lowercase			  =							tf.convert_to_tensor(SCREAMING_SNAKE_CASE_	)
																__lowercase			  =							model(SCREAMING_SNAKE_CASE_       ,**SCREAMING_SNAKE_CASE_	)[0]
																self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]	)
																self.assertTrue(not np.any(np.isnan(loss.numpy()	)	)	)

                # Test that model correctly compute the loss with a dict
										__lowercase			  =							self._prepare_for_class(inputs_dict.copy()       ,SCREAMING_SNAKE_CASE_       ,return_labels=SCREAMING_SNAKE_CASE_	)
										__lowercase			  =							model(SCREAMING_SNAKE_CASE_	)[0]
										self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]	)

										# Test that model correctly compute the loss with a tuple
										__lowercase			  =							self._prepare_for_class(inputs_dict.copy()       ,SCREAMING_SNAKE_CASE_       ,return_labels=SCREAMING_SNAKE_CASE_	)

										# Get keys that were added with the _prepare_for_class function
										__lowercase			  =							prepared_for_class.keys() - inputs_dict.keys()
										__lowercase			  =							inspect.signature(model.call	).parameters
										__lowercase			  =							list(signature.keys()	)

										# Create a dictionary holding the location of the tensors in the tuple
										__lowercase			  =							{0: """input_ids"""}
										for label_key in label_keys:
													__lowercase			  =							signature_names.index(SCREAMING_SNAKE_CASE_	)
													__lowercase			  =							label_key
										__lowercase			  =							sorted(tuple_index_mapping.items()	)
										# Initialize a list with their default values, update the values and convert to a tuple
										__lowercase			  =							[]

										for name in signature_names:
													if name != "kwargs":
																list_input.append(signature[name].default	)

										for index, value in sorted_tuple_index_mapping:
													__lowercase			  =							prepared_for_class[value]

										__lowercase			  =							tuple(SCREAMING_SNAKE_CASE_	)

										# Send to model
										__lowercase			  =							model(tuple_input[:-1]	)[0]

										self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]	)


	def   _UpperCAmelCase       (self	)							->							List[str]:







				'''simple docstring'''





				(
				    __lowercase							
				)			  =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_model(SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_	)


	def   _UpperCAmelCase       (self	)							->							Any:







				'''simple docstring'''





				(
				    __lowercase							
				)			  =							self.model_tester.prepare_config_and_inputs()
				for type in ["absolute", "relative_key", "relative_key_query"]:
							__lowercase			  =							type
							self.model_tester.create_and_check_model(SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_	)


	def   _UpperCAmelCase       (self	)							->							Any:







				'''simple docstring'''





				(
				    __lowercase							
				)			  =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_sequence_classification(
				    SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_	)


	def   _UpperCAmelCase       (self	)							->							int:







				'''simple docstring'''





				(
				    __lowercase							
				)			  =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_token_classification(
				    SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_	)


	def   _UpperCAmelCase       (self	)							->							List[Any]:







				'''simple docstring'''





				(
				    __lowercase							
				)			  =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_for_question_answering(
				    SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_	)


	@slow
	def   _UpperCAmelCase       (self	)							->							Tuple:







				'''simple docstring'''





				for model_name in TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__lowercase			  =							TFLayoutLMvaModel.from_pretrained(SCREAMING_SNAKE_CASE_	)
							self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)





def 				_lowerCAmelCase  (			):
			__lowercase			  =							Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''			)
			return image






@require_tf
class 							__lowercase    ( unittest.TestCase  ):







	'''simple docstring'''

	@cached_property
	def   _UpperCAmelCase       (self	)							->							Dict:







				'''simple docstring'''





				return LayoutLMvaImageProcessor(apply_ocr=SCREAMING_SNAKE_CASE_	) if is_vision_available() else None


	@slow
	def   _UpperCAmelCase       (self	)							->							List[str]:







				'''simple docstring'''





				__lowercase			  =							TFLayoutLMvaModel.from_pretrained('''microsoft/layoutlmv3-base'''	)

				__lowercase			  =							self.default_image_processor
				__lowercase			  =							prepare_img()
				__lowercase			  =							image_processor(images=SCREAMING_SNAKE_CASE_       ,return_tensors='''tf'''	).pixel_values

				__lowercase			  =							tf.constant([[1, 2]]	)
				__lowercase			  =							tf.expand_dims(tf.constant([[1, 2, 3, 4], [5, 6, 7, 8]]	)       ,axis=0	)

				# forward pass
				__lowercase			  =							model(input_ids=SCREAMING_SNAKE_CASE_       ,bbox=SCREAMING_SNAKE_CASE_       ,pixel_values=SCREAMING_SNAKE_CASE_       ,training=SCREAMING_SNAKE_CASE_	)

				# verify the logits
				__lowercase			  =							(1, 199, 768)
				self.assertEqual(outputs.last_hidden_state.shape       ,SCREAMING_SNAKE_CASE_	)

				__lowercase			  =							tf.constant(
				    [[-0.0_5_2_9, 0.3_6_1_8, 0.1_6_3_2], [-0.1_5_8_7, -0.1_6_6_7, -0.0_4_0_0], [-0.1_5_5_7, -0.1_6_7_1, -0.0_5_0_5]]	)

				self.assertTrue(np.allclose(outputs.last_hidden_state[0, :3, :3]       ,SCREAMING_SNAKE_CASE_       ,atol=1E-4	)	)












'''simple docstring'''



import numpy as np




def 				_lowerCAmelCase  (			lowerCamelCase_     :					np.array			):
			return 1 / (1 + np.exp(-vector			))




def 				_lowerCAmelCase  (			lowerCamelCase_     :					np.array			):
			return vector * sigmoid(1.7_02 * vector			)


if __name__ == "__main__":
	import doctest

	doctest.testmod()





