

'''simple docstring'''


import json
import os
from dataclasses import dataclass
from functools import partial
from typing import Callable

import flax.linen as nn
import jax
import jax.numpy as jnp
import joblib
import optax
import wandb
from flax import jax_utils, struct, traverse_util
from flax.serialization import from_bytes, to_bytes
from flax.training import train_state
from flax.training.common_utils import shard
from tqdm.auto import tqdm

from transformers import BigBirdConfig, FlaxBigBirdForQuestionAnswering
from transformers.models.big_bird.modeling_flax_big_bird import FlaxBigBirdForQuestionAnsweringModule



class 					lowercase						(  UpperCamelCase_ ):
							_lowerCamelCase		:      BigBirdConfig
							_lowerCamelCase		:      jnp.dtype=   jnp.floataa
							_lowerCamelCase		:      bool=   True


							def 						_snake_case							(			self)							->				Dict:
								super().setup()
								UpperCAmelCase_		:      str       	=					nn.Dense(5    ,			dtype=self.dtype)





							def __call__(			self    ,			*_snake_case    ,			**_snake_case)							->				List[Any]:
								UpperCAmelCase_		:      Optional[Any]       	=					super().__call__(*_a    ,			**_a)
								UpperCAmelCase_		:      List[Any]       	=					self.cls(outputs[2])
								return outputs[:2] + (cls_out,)



class 					lowercase						(  UpperCamelCase_ ):
							_lowerCamelCase		:      List[str]=   FlaxBigBirdForNaturalQuestionsModule







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase  )    ->    Union[str, Any]:

	'''simple docstring'''





	def cross_entropy(UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase=None  ):
		UpperCAmelCase_		:      Dict       	=					logits.shape[-1]
		UpperCAmelCase_		:      str       	=					(labels[..., None] == jnp.arange(__lowerCAmelCase  )[None]).astype('f4'  )
		UpperCAmelCase_		:      Optional[Any]       	=					jax.nn.log_softmax(__lowerCAmelCase   ,axis=-1  )
		UpperCAmelCase_		:      int       	=					-jnp.sum(labels * logits   ,axis=-1  )
		if reduction is not None:
			UpperCAmelCase_		:      str       	=					reduction(__lowerCAmelCase  )
		return loss

	UpperCAmelCase_		:      List[str]       	=					partial(__lowerCAmelCase   ,reduction=jnp.mean  )
	UpperCAmelCase_		:      str       	=					cross_entropy(__lowerCAmelCase   ,__lowerCAmelCase  )
	UpperCAmelCase_		:      Union[str, Any]       	=					cross_entropy(__lowerCAmelCase   ,__lowerCAmelCase  )
	UpperCAmelCase_		:      List[Any]       	=					cross_entropy(__lowerCAmelCase   ,__lowerCAmelCase  )
	return (start_loss + end_loss + pooled_loss) / 3



@dataclass
class 					lowercase						:
							_lowerCamelCase		:      str=   "google/bigbird-roberta-base"
							_lowerCamelCase		:      int=   3000
							_lowerCamelCase		:      int=   10500

							_lowerCamelCase		:      int=   128
							_lowerCamelCase		:      int=   3

							_lowerCamelCase		:      int=   1
							_lowerCamelCase		:      int=   5

							# tx_args
							_lowerCamelCase		:      float=   3e-5
							_lowerCamelCase		:      float=   0.0
							_lowerCamelCase		:      int=   20000
							_lowerCamelCase		:      float=   0.0095

							_lowerCamelCase		:      str=   "bigbird-roberta-natural-questions"
							_lowerCamelCase		:      str=   "training-expt"
							_lowerCamelCase		:      str=   "data/nq-training.jsonl"
							_lowerCamelCase		:      str=   "data/nq-validation.jsonl"


							def 						_snake_case							(			self)							->				Optional[int]:
								os.makedirs(self.base_dir    ,			exist_ok=_a)
								UpperCAmelCase_		:      Tuple       	=					os.path.join(self.base_dir    ,			self.save_dir)
								UpperCAmelCase_		:      Optional[int]       	=					self.batch_size_per_device * jax.device_count()



@dataclass
class 					lowercase						:
							_lowerCamelCase		:      int
							_lowerCamelCase		:      int=   4096  # no dynamic padding on TPUs


							def __call__(			self    ,			_snake_case)							->				int:
								UpperCAmelCase_		:      int       	=					self.collate_fn(_a)
								UpperCAmelCase_		:      List[str]       	=					jax.tree_util.tree_map(_a    ,			_a)
								return batch


							def 						_snake_case							(			self    ,			_snake_case)							->				Optional[int]:
								UpperCAmelCase_		:      int       	=					self.fetch_inputs(features['input_ids'])
								UpperCAmelCase_		:      Tuple       	=					{
								    """input_ids""": jnp.array(_a    ,			dtype=jnp.intaa),
								    """attention_mask""": jnp.array(_a    ,			dtype=jnp.intaa),
								    """start_labels""": jnp.array(features['start_token']    ,			dtype=jnp.intaa),
								    """end_labels""": jnp.array(features['end_token']    ,			dtype=jnp.intaa),
								    """pooled_labels""": jnp.array(features['category']    ,			dtype=jnp.intaa),
								}
								return batch


							def 						_snake_case							(			self    ,			_snake_case)							->				List[str]:
								UpperCAmelCase_		:      str       	=					[self._fetch_inputs(_a) for ids in input_ids]
								return zip(*_a)





							def 						_snake_case							(			self    ,			_snake_case)							->				int:
								UpperCAmelCase_		:      List[str]       	=					[1 for _ in range(len(_a))]
								while len(_a) < self.max_length:
									input_ids.append(self.pad_id)
									attention_mask.append(0)
								return input_ids, attention_mask







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase=None  )    ->    List[str]:

	'''simple docstring'''





	if seed is not None:
		UpperCAmelCase_		:      Optional[int]       	=					dataset.shuffle(seed=__lowerCAmelCase  )
	for i in range(len(__lowerCAmelCase  ) // batch_size  ):
		UpperCAmelCase_		:      Optional[int]       	=					dataset[i * batch_size : (i + 1) * batch_size]
		yield dict(__lowerCAmelCase  )







@partial(jax.pmap   ,axis_name='batch'  )
def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase   ,**UpperCamelCase  )    ->    Tuple:

	'''simple docstring'''





	def loss_fn(UpperCamelCase  ):
		UpperCAmelCase_		:      Any       	=					model_inputs.pop('start_labels'  )
		UpperCAmelCase_		:      Optional[int]       	=					model_inputs.pop('end_labels'  )
		UpperCAmelCase_		:      str       	=					model_inputs.pop('pooled_labels'  )

		UpperCAmelCase_		:      Dict       	=					state.apply_fn(**__lowerCAmelCase   ,params=__lowerCAmelCase   ,dropout_rng=__lowerCAmelCase   ,train=__lowerCAmelCase  )
		UpperCAmelCase_		:      List[str]       	=					outputs

		return state.loss_fn(
		    __lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,)

	UpperCAmelCase_		:      Union[str, Any]       	=					jax.random.split(__lowerCAmelCase  )
	UpperCAmelCase_		:      int       	=					jax.value_and_grad(__lowerCAmelCase  )
	UpperCAmelCase_		:      Tuple       	=					grad_fn(state.params  )
	UpperCAmelCase_		:      Optional[int]       	=					jax.lax.pmean({'loss': loss}   ,axis_name='batch'  )
	UpperCAmelCase_		:      int       	=					jax.lax.pmean(__lowerCAmelCase   ,'batch'  )

	UpperCAmelCase_		:      Optional[int]       	=					state.apply_gradients(grads=__lowerCAmelCase  )
	return state, metrics, new_drp_rng







@partial(jax.pmap   ,axis_name='batch'  )
def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,**UpperCamelCase  )    ->    str:

	'''simple docstring'''





	UpperCAmelCase_		:      Dict       	=					model_inputs.pop('start_labels'  )
	UpperCAmelCase_		:      Optional[int]       	=					model_inputs.pop('end_labels'  )
	UpperCAmelCase_		:      List[str]       	=					model_inputs.pop('pooled_labels'  )

	UpperCAmelCase_		:      Dict       	=					state.apply_fn(**__lowerCAmelCase   ,params=state.params   ,train=__lowerCAmelCase  )
	UpperCAmelCase_		:      Optional[Any]       	=					outputs

	UpperCAmelCase_		:      Any       	=					state.loss_fn(__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase  )
	UpperCAmelCase_		:      List[str]       	=					jax.lax.pmean({'loss': loss}   ,axis_name='batch'  )
	return metrics



class 					lowercase						(  train_state.TrainState ):
							_lowerCamelCase		:      Callable=   struct.field(pytree_node=UpperCamelCase_ )



@dataclass
class 					lowercase						:
							_lowerCamelCase		:      Args
							_lowerCamelCase		:      Callable
							_lowerCamelCase		:      Callable
							_lowerCamelCase		:      Callable
							_lowerCamelCase		:      Callable
							_lowerCamelCase		:      wandb
							_lowerCamelCase		:      Callable=   None


							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case    ,			_snake_case    ,			_snake_case=None)							->				str:
								UpperCAmelCase_		:      List[Any]       	=					model.params
								UpperCAmelCase_		:      Any       	=					TrainState.create(
								    apply_fn=model.__call__    ,			params=_a    ,			tx=_a    ,			loss_fn=_a    ,			)
								if ckpt_dir is not None:
									UpperCAmelCase_		:      List[str]       	=					restore_checkpoint(_a    ,			_a)
									UpperCAmelCase_		:      str       	=					{
									    """lr""": args.lr,
									    """init_lr""": args.init_lr,
									    """warmup_steps""": args.warmup_steps,
									    """num_train_steps""": num_train_steps,
									    """weight_decay""": args.weight_decay,
									}
									UpperCAmelCase_		:      Union[str, Any]       	=					build_tx(**_a)
									UpperCAmelCase_		:      int       	=					train_state.TrainState(
									    step=_a    ,			apply_fn=model.__call__    ,			params=_a    ,			tx=_a    ,			opt_state=_a    ,			)
									UpperCAmelCase_		:      int       	=					args
									UpperCAmelCase_		:      Optional[Any]       	=					data_collator
									UpperCAmelCase_		:      Union[str, Any]       	=					lr
									UpperCAmelCase_		:      int       	=					params
								UpperCAmelCase_		:      str       	=					jax_utils.replicate(_a)
								return state


							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case    ,			_snake_case)							->				Optional[Any]:
								UpperCAmelCase_		:      int       	=					self.args
								UpperCAmelCase_		:      int       	=					len(_a) // args.batch_size

								UpperCAmelCase_		:      Union[str, Any]       	=					jax.random.PRNGKey(0)
								UpperCAmelCase_		:      Union[str, Any]       	=					jax.random.split(_a    ,			jax.device_count())
								for epoch in range(args.max_epochs):
									UpperCAmelCase_		:      Optional[int]       	=					jnp.array(0    ,			dtype=jnp.floataa)
									UpperCAmelCase_		:      int       	=					get_batched_dataset(_a    ,			args.batch_size    ,			seed=_a)
									UpperCAmelCase_		:      int       	=					0
									for batch in tqdm(_a    ,			total=_a    ,			desc=F"""Running EPOCH-{epoch}"""):
										UpperCAmelCase_		:      Union[str, Any]       	=					self.data_collator(_a)
										UpperCAmelCase_		:      Dict       	=					self.train_step_fn(_a    ,			_a    ,			**_a)
										running_loss += jax_utils.unreplicate(metrics['loss'])
										i += 1
										if i % args.logging_steps == 0:
											UpperCAmelCase_		:      Any       	=					jax_utils.unreplicate(state.step)
											UpperCAmelCase_		:      Optional[Any]       	=					running_loss.item() / i
											UpperCAmelCase_		:      Dict       	=					self.scheduler_fn(state_step - 1)

											UpperCAmelCase_		:      Optional[Any]       	=					self.evaluate(_a    ,			_a)
											UpperCAmelCase_		:      Optional[int]       	=					{
											    """step""": state_step.item(),
											    """eval_loss""": eval_loss.item(),
											    """tr_loss""": tr_loss,
											    """lr""": lr.item(),
											}
											tqdm.write(str(_a))
											self.logger.log(_a    ,			commit=_a)

										if i % args.save_steps == 0:
											self.save_checkpoint(args.save_dir + F"""-e{epoch}-s{i}"""    ,			state=_a)


							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case)							->				int:
								UpperCAmelCase_		:      Optional[Any]       	=					get_batched_dataset(_a    ,			self.args.batch_size)
								UpperCAmelCase_		:      Optional[Any]       	=					len(_a) // self.args.batch_size
								UpperCAmelCase_		:      Optional[Any]       	=					jnp.array(0    ,			dtype=jnp.floataa)
								UpperCAmelCase_		:      Union[str, Any]       	=					0
								for batch in tqdm(_a    ,			total=_a    ,			desc='Evaluating ... '):
									UpperCAmelCase_		:      Optional[Any]       	=					self.data_collator(_a)
									UpperCAmelCase_		:      List[str]       	=					self.val_step_fn(_a    ,			**_a)
									running_loss += jax_utils.unreplicate(metrics['loss'])
									i += 1
								return running_loss / i





							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case)							->				List[str]:
								UpperCAmelCase_		:      Dict       	=					jax_utils.unreplicate(_a)
								print(F"""SAVING CHECKPOINT IN {save_dir}"""    ,			end=' ... ')
								self.model_save_fn(_a    ,			params=state.params)
								with open(os.path.join(_a    ,			'opt_state.msgpack')    ,			'wb') as f:
									f.write(to_bytes(state.opt_state))
								joblib.dump(self.args    ,			os.path.join(_a    ,			'args.joblib'))
								joblib.dump(self.data_collator    ,			os.path.join(_a    ,			'data_collator.joblib'))
								with open(os.path.join(_a    ,			'training_state.json')    ,			'w') as f:
									json.dump({'step': state.step.item()}    ,			_a)
								print('DONE')







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase  )    ->    str:

	'''simple docstring'''





	print(f"""RESTORING CHECKPOINT FROM {save_dir}"""   ,end=' ... '  )
	with open(os.path.join(__lowerCAmelCase   ,'flax_model.msgpack'  )   ,'rb'  ) as f:
		UpperCAmelCase_		:      Optional[Any]       	=					from_bytes(state.params   ,f.read()  )

	with open(os.path.join(__lowerCAmelCase   ,'opt_state.msgpack'  )   ,'rb'  ) as f:
		UpperCAmelCase_		:      Dict       	=					from_bytes(state.opt_state   ,f.read()  )

	UpperCAmelCase_		:      Any       	=					joblib.load(os.path.join(__lowerCAmelCase   ,'args.joblib'  )  )
	UpperCAmelCase_		:      Dict       	=					joblib.load(os.path.join(__lowerCAmelCase   ,'data_collator.joblib'  )  )

	with open(os.path.join(__lowerCAmelCase   ,'training_state.json'  )   ,'r'  ) as f:
		UpperCAmelCase_		:      str       	=					json.load(__lowerCAmelCase  )
	UpperCAmelCase_		:      Optional[Any]       	=					training_state["""step"""]

	print('DONE'  )
	return params, opt_state, step, args, data_collator







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase  )    ->    str:

	'''simple docstring'''





	UpperCAmelCase_		:      int       	=					num_train_steps - warmup_steps
	UpperCAmelCase_		:      Union[str, Any]       	=					optax.linear_schedule(init_value=__lowerCAmelCase   ,end_value=__lowerCAmelCase   ,transition_steps=__lowerCAmelCase  )
	UpperCAmelCase_		:      int       	=					optax.linear_schedule(init_value=__lowerCAmelCase   ,end_value=1e-7   ,transition_steps=__lowerCAmelCase  )
	UpperCAmelCase_		:      Dict       	=					optax.join_schedules(schedules=[warmup_fn, decay_fn]   ,boundaries=[warmup_steps]  )
	return lr







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase  )    ->    List[Any]:

	'''simple docstring'''





	def weight_decay_mask(UpperCamelCase  ):
		UpperCAmelCase_		:      List[str]       	=					traverse_util.flatten_dict(__lowerCAmelCase  )
		UpperCAmelCase_		:      Dict       	=					{k: (v[-1] != """bias""" and v[-2:] != ("""LayerNorm""", """scale""")) for k, v in params.items()}
		return traverse_util.unflatten_dict(__lowerCAmelCase  )

	UpperCAmelCase_		:      List[Any]       	=					scheduler_fn(__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase  )

	UpperCAmelCase_		:      List[str]       	=					optax.adamw(learning_rate=__lowerCAmelCase   ,weight_decay=__lowerCAmelCase   ,mask=__lowerCAmelCase  )
	return tx, lr









'''simple docstring'''


import numpy



class 					lowercase						:


							def __init__(			self    ,			_snake_case    ,			_snake_case)							->				None:
								UpperCAmelCase_		:      Optional[Any]       	=					input_array

								# Random initial weights are assigned where first argument is the
								# number of nodes in previous layer and second argument is the
								# number of nodes in the next layer.

								# Random initial weights are assigned.
								# self.input_array.shape[1] is used to represent number of nodes in input layer.
								# First hidden layer consists of 4 nodes.
								UpperCAmelCase_		:      Tuple       	=					numpy.random.rand(
								    self.input_array.shape[1]    ,			4)

								# Random initial values for the first hidden layer.
								# First hidden layer has 4 nodes.
								# Second hidden layer has 3 nodes.
								UpperCAmelCase_		:      List[str]       	=					numpy.random.rand(
								    4    ,			3)

								# Random initial values for the second hidden layer.
								# Second hidden layer has 3 nodes.
								# Output layer has 1 node.
								UpperCAmelCase_		:      Dict       	=					numpy.random.rand(3    ,			1)

								# Real output values provided.
								UpperCAmelCase_		:      str       	=					output_array

								# Predicted output values by the neural network.
								# Predicted_output array initially consists of zeroes.
								UpperCAmelCase_		:      Union[str, Any]       	=					numpy.zeros(output_array.shape)


							def 						_snake_case							(			self)							->				numpy.ndarray:
								UpperCAmelCase_		:      Any       	=					sigmoid(
								    numpy.dot(self.input_array    ,			self.input_layer_and_first_hidden_layer_weights))

								# layer_between_first_hidden_layer_and_second_hidden_layer is the layer
								# connecting the first hidden set of nodes with the second hidden set of nodes.
								UpperCAmelCase_		:      Tuple       	=					sigmoid(
								    numpy.dot(
								        self.layer_between_input_and_first_hidden_layer    ,			self.first_hidden_layer_and_second_hidden_layer_weights    ,			))

								# layer_between_second_hidden_layer_and_output is the layer connecting
								# second hidden layer with the output node.
								UpperCAmelCase_		:      int       	=					sigmoid(
								    numpy.dot(
								        self.layer_between_first_hidden_layer_and_second_hidden_layer    ,			self.second_hidden_layer_and_output_layer_weights    ,			))

								return self.layer_between_second_hidden_layer_and_output


							def 						_snake_case							(			self)							->				None:
								UpperCAmelCase_		:      Optional[int]       	=					numpy.dot(
								    self.layer_between_first_hidden_layer_and_second_hidden_layer.T    ,			2
								    * (self.output_array - self.predicted_output)
								    * sigmoid_derivative(self.predicted_output)    ,			)
								UpperCAmelCase_		:      Any       	=					numpy.dot(
								    self.layer_between_input_and_first_hidden_layer.T    ,			numpy.dot(
								        2
								        * (self.output_array - self.predicted_output)
								        * sigmoid_derivative(self.predicted_output)    ,			self.second_hidden_layer_and_output_layer_weights.T    ,			)
								    * sigmoid_derivative(
								        self.layer_between_first_hidden_layer_and_second_hidden_layer)    ,			)
								UpperCAmelCase_		:      Tuple       	=					numpy.dot(
								    self.input_array.T    ,			numpy.dot(
								        numpy.dot(
								            2
								            * (self.output_array - self.predicted_output)
								            * sigmoid_derivative(self.predicted_output)    ,			self.second_hidden_layer_and_output_layer_weights.T    ,			)
								        * sigmoid_derivative(
								            self.layer_between_first_hidden_layer_and_second_hidden_layer)    ,			self.first_hidden_layer_and_second_hidden_layer_weights.T    ,			)
								    * sigmoid_derivative(self.layer_between_input_and_first_hidden_layer)    ,			)

								self.input_layer_and_first_hidden_layer_weights += (
								    updated_input_layer_and_first_hidden_layer_weights
								)
								self.first_hidden_layer_and_second_hidden_layer_weights += (
								    updated_first_hidden_layer_and_second_hidden_layer_weights
								)
								self.second_hidden_layer_and_output_layer_weights += (
								    updated_second_hidden_layer_and_output_layer_weights
								)


							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case    ,			_snake_case)							->				None:
								for iteration in range(1    ,			iterations + 1):
									UpperCAmelCase_		:      int       	=					self.feedforward()
									self.back_propagation()
									if give_loss:
										UpperCAmelCase_		:      List[Any]       	=					numpy.mean(numpy.square(output - self.feedforward()))
										print(F"""Iteration {iteration} Loss: {loss}""")





							def 						_snake_case							(			self    ,			_snake_case)							->				int:
								UpperCAmelCase_		:      Optional[int]       	=					input_arr

								UpperCAmelCase_		:      Tuple       	=					sigmoid(
								    numpy.dot(self.array    ,			self.input_layer_and_first_hidden_layer_weights))

								UpperCAmelCase_		:      Optional[int]       	=					sigmoid(
								    numpy.dot(
								        self.layer_between_input_and_first_hidden_layer    ,			self.first_hidden_layer_and_second_hidden_layer_weights    ,			))

								UpperCAmelCase_		:      int       	=					sigmoid(
								    numpy.dot(
								        self.layer_between_first_hidden_layer_and_second_hidden_layer    ,			self.second_hidden_layer_and_output_layer_weights    ,			))

								return int(self.layer_between_second_hidden_layer_and_output > 0.6)







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase  )    ->    numpy.ndarray:
	return 1 / (1 + numpy.exp(-value  ))







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase  )    ->    numpy.ndarray:
	return (value) * (1 - (value))







def 						SCREAMING_SNAKE_CASE(  )    ->    int:
	UpperCAmelCase_		:      Optional[int]       	=					numpy.array(
	    (
	        [0, 0, 0],
	        [0, 0, 1],
	        [0, 1, 0],
	        [0, 1, 1],
	        [1, 0, 0],
	        [1, 0, 1],
	        [1, 1, 0],
	        [1, 1, 1],
	    )   ,dtype=numpy.floataa   ,)

	# True output values for the given input values.
	UpperCAmelCase_		:      Dict       	=					numpy.array(([0], [1], [1], [0], [1], [0], [0], [1])   ,dtype=numpy.floataa  )

	# Calling neural network class.
	UpperCAmelCase_		:      List[str]       	=					TwoHiddenLayerNeuralNetwork(
	    input_array=UpperCamelCase   ,output_array=UpperCamelCase  )

	# Calling training function.
	# Set give_loss to True if you want to see loss in every iteration.
	neural_network.train(output=UpperCamelCase   ,iterations=1_0   ,give_loss=UpperCamelCase  )

	return neural_network.predict(numpy.array(([1, 1, 1])   ,dtype=numpy.floataa  )  )


if __name__ == "__main__":
						example()






