





def 		__SCREAMING_SNAKE_CASE						(       UpperCamelCase__ = "mytext.txt"    ,    UpperCamelCase__ = False				)						->       None:







							'''simple docstring'''

							import socket

							UpperCAmelCase     	=       1_2312  # Reserve a port for your service.
							UpperCAmelCase     	=       socket.socket()  # Create a socket object
							UpperCAmelCase     	=       socket.gethostname()  # Get local machine name
							sock.bind((host, port)				)  # Bind to the port
							sock.listen(5				)  # Now wait for client connection.

							print('''Server listening....'''				)

							while True:
														UpperCAmelCase	,    UpperCAmelCase     	=       sock.accept()  # Establish connection with client.
														print(F"""Got connection from {addr}"""				)
														UpperCAmelCase     	=       conn.recv(1024				)
														print(F"""Server received: {data = }"""				)

														with open(lowerCamelCase__    ,    '''rb'''				) as in_file:
																					UpperCAmelCase     	=       in_file.read(1024				)
																					while data:
																												conn.send(lowerCamelCase__				)
																												print(F"""Sent {data!r}"""				)
																												UpperCAmelCase     	=       in_file.read(1024				)

														print('''Done sending'''				)
														conn.close()
														if testing:  # Allow the test to complete
																					break

							sock.shutdown(1				)
							sock.close()


if __name__ == "__main__":
				send_file()










import numpy as np





def 		__SCREAMING_SNAKE_CASE						(       UpperCamelCase__    ,    UpperCamelCase__    ,    UpperCamelCase__				)						->       int:







			'''simple docstring'''

			UpperCAmelCase     	=       n_draws * class_counts / class_counts.sum()
			# floored means we don't overshoot n_samples, but probably undershoot
			UpperCAmelCase     	=       np.floor(UpperCamelCase__				)
			# we add samples according to how much "left over" probability
			# they had, until we arrive at n_samples
			UpperCAmelCase     	=       int(n_draws - floored.sum()				)
			if need_to_add > 0:
						UpperCAmelCase     	=       continuous - floored
						UpperCAmelCase     	=       np.sort(np.unique(UpperCamelCase__				)				)[::-1]
						# add according to remainder, but break ties
						# randomly to avoid biases
						for value in values:
									((UpperCAmelCase)	,    )     	=       np.where(remainder == value				)
									# if we need_to_add less than what's in inds
									# we draw randomly from them.
									# if we need to add more, we add them all and
									# go to the next value
									UpperCAmelCase     	=       min(len(UpperCamelCase__				)    ,    UpperCamelCase__				)
									UpperCAmelCase     	=       rng.choice(UpperCamelCase__    ,    size=UpperCamelCase__    ,    replace=UpperCamelCase__				)
									floored[inds] += 1
									need_to_add -= add_now
									if need_to_add == 0:
												break
			return floored.astype(np.intaa				)






def 		__SCREAMING_SNAKE_CASE						(       UpperCamelCase__    ,    UpperCamelCase__    ,    UpperCamelCase__    ,    UpperCamelCase__    ,    UpperCamelCase__=10				)						->       Any:







			'''simple docstring'''

			UpperCAmelCase	,    UpperCAmelCase     	=       np.unique(UpperCamelCase__    ,    return_inverse=UpperCamelCase__				)
			UpperCAmelCase     	=       classes.shape[0]
			UpperCAmelCase     	=       np.bincount(UpperCamelCase__				)
			if np.min(UpperCamelCase__				) < 2:
						raise ValueError('''Minimum class count error'''				)
			if n_train < n_classes:
						raise ValueError(
						    '''The train_size = %d should be greater or ''' '''equal to the number of classes = %d''' % (n_train, n_classes)				)
			if n_test < n_classes:
						raise ValueError(
						    '''The test_size = %d should be greater or ''' '''equal to the number of classes = %d''' % (n_test, n_classes)				)
			UpperCAmelCase     	=       np.split(np.argsort(UpperCamelCase__    ,    kind='''mergesort'''				)    ,    np.cumsum(UpperCamelCase__				)[:-1]				)
			for _ in range(UpperCamelCase__				):
						UpperCAmelCase     	=       approximate_mode(UpperCamelCase__    ,    UpperCamelCase__    ,    UpperCamelCase__				)
						UpperCAmelCase     	=       class_counts - n_i
						UpperCAmelCase     	=       approximate_mode(UpperCamelCase__    ,    UpperCamelCase__    ,    UpperCamelCase__				)

						UpperCAmelCase     	=       []
						UpperCAmelCase     	=       []

						for i in range(UpperCamelCase__				):
									UpperCAmelCase     	=       rng.permutation(class_counts[i]				)
									UpperCAmelCase     	=       class_indices[i].take(UpperCamelCase__    ,    mode='''clip'''				)
									train.extend(perm_indices_class_i[: n_i[i]]				)
									test.extend(perm_indices_class_i[n_i[i] : n_i[i] + t_i[i]]				)
						UpperCAmelCase     	=       rng.permutation(UpperCamelCase__				)
						UpperCAmelCase     	=       rng.permutation(UpperCamelCase__				)

						yield train, test



