
"""simple docstring"""
def  lowercase     (_lowerCAmelCase = 10 ,    _lowerCAmelCase = 1000 ,    _lowerCAmelCase = True						):
						assert (
						    isinstance(_lowerCAmelCase ,    _lowerCAmelCase						)
						    and isinstance(_lowerCAmelCase ,    _lowerCAmelCase						)
						    and isinstance(_lowerCAmelCase ,    _lowerCAmelCase						)
						), "Invalid type of value(s) specified to function!"

						if min_val > max_val:
												raise ValueError("""Invalid value for min_val or max_val (min_value < max_value)"""						)
						return min_val if option else max_val

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase						):
						return int((number_a + number_a) / 2						)

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase ,    _lowerCAmelCase						):
						assert (
						    isinstance(_lowerCAmelCase ,    _lowerCAmelCase						) and isinstance(_lowerCAmelCase ,    _lowerCAmelCase						) and isinstance(_lowerCAmelCase ,    _lowerCAmelCase						)
						), 'argument values must be type of "int"'

						if lower > higher:
												raise ValueError("""argument value for lower and higher must be(lower > higher)"""						)

						if not lower < to_guess < higher:
												raise ValueError(
												    """guess value must be within the range of lower and higher value"""						)

						def answer(_lowerCAmelCase						) -> str:
												if number > to_guess:
																		return "high"
												elif number < to_guess:
																		return "low"
												else:
																		return "same"

						print("""started..."""						)

						__lowerCAmelCase     =  lower
						__lowerCAmelCase     =  higher

						__lowerCAmelCase     =  []

						while True:
												__lowerCAmelCase     =  get_avg(_lowerCAmelCase ,    _lowerCAmelCase						)
												last_numbers.append(_lowerCAmelCase						)

												if answer(_lowerCAmelCase						) == "low":
																		__lowerCAmelCase     =  number
												elif answer(_lowerCAmelCase						) == "high":
																		__lowerCAmelCase     =  number
												else:
																		break

						print(f"""guess the number : {last_numbers[-1]}"""						)
						print(f"""details : {last_numbers!s}"""						)

def  lowercase     ():
						__lowerCAmelCase     =  int(input("""Enter lower value : """						).strip()						)
						__lowerCAmelCase     =  int(input("""Enter high value : """						).strip()						)
						__lowerCAmelCase     =  int(input("""Enter value to guess : """						).strip()						)
						guess_the_number(_lowerCAmelCase ,    _lowerCAmelCase ,    _lowerCAmelCase						)


if __name__ == "__main__":
			main()


"""simple docstring"""
import os
import socket
from contextlib import contextmanager

import torch

from ..commands.config.default import write_basic_config  # noqa: F401
from ..state import PartialState
from .dataclasses import DistributedType
from .imports import is_deepspeed_available, is_tpu_available
from .transformer_engine import convert_model
from .versions import is_torch_version


if is_deepspeed_available():
			from deepspeed import DeepSpeedEngine

if is_tpu_available(check_device=False):
			import torch_xla.core.xla_model as xm

def  lowercase     (_lowerCAmelCase						):
						if is_torch_version("""<""" ,    """2.0.0"""						) or not hasattr(_lowerCAmelCase ,    """_dynamo"""						):
												return False
						return isinstance(_lowerCAmelCase ,    torch._dynamo.eval_frame.OptimizedModule						)

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase = True						):
						__lowerCAmelCase     =  (torch.nn.parallel.DistributedDataParallel, torch.nn.DataParallel)

						__lowerCAmelCase     =  is_compiled_module(_lowerCAmelCase						)
						if is_compiled:
												__lowerCAmelCase     =  model
												__lowerCAmelCase     =  model._orig_mod

						if is_deepspeed_available():
												options += (DeepSpeedEngine,)

						while isinstance(_lowerCAmelCase ,    _lowerCAmelCase						):
												__lowerCAmelCase     =  model.module

						if not keep_fpaa_wrapper:
												__lowerCAmelCase     =  getattr(_lowerCAmelCase ,    """forward"""						)
												__lowerCAmelCase     =  model.__dict__.pop("""_original_forward""" ,    _lowerCAmelCase						)
												if original_forward is not None:
																		while hasattr(_lowerCAmelCase ,    """__wrapped__"""						):
																								__lowerCAmelCase     =  forward.__wrapped__
																								if forward == original_forward:
																														break
																		__lowerCAmelCase     =  forward
												if getattr(_lowerCAmelCase ,    """_converted_to_transformer_engine""" ,    _lowerCAmelCase						):
																		convert_model(_lowerCAmelCase ,    to_transformer_engine=_lowerCAmelCase						)

						if is_compiled:
												__lowerCAmelCase     =  model
												__lowerCAmelCase     =  compiled_model

						return model

def  lowercase     ():
						PartialState().wait_for_everyone()

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase						):
						if PartialState().distributed_type == DistributedType.TPU:
												xm.save(_lowerCAmelCase ,    _lowerCAmelCase						)
						elif PartialState().local_process_index == 0:
												torch.save(_lowerCAmelCase ,    _lowerCAmelCase						)

@contextmanager
def  lowercase     (**_lowerCAmelCase						):
						for key, value in kwargs.items():
												__lowerCAmelCase     =  str(_lowerCAmelCase						)

						yield

						for key in kwargs:
												if key.upper() in os.environ:
																		del os.environ[key.upper()]

def  lowercase     (_lowerCAmelCase						):
						if not hasattr(_lowerCAmelCase ,    """__qualname__"""						) and not hasattr(_lowerCAmelCase ,    """__name__"""						):
												__lowerCAmelCase     =  getattr(_lowerCAmelCase ,    """__class__""" ,    _lowerCAmelCase						)
						if hasattr(_lowerCAmelCase ,    """__qualname__"""						):
												return obj.__qualname__
						if hasattr(_lowerCAmelCase ,    """__name__"""						):
												return obj.__name__
						return str(_lowerCAmelCase						)

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase						):
						for key, value in source.items():
												if isinstance(_lowerCAmelCase ,    _lowerCAmelCase						):
																		__lowerCAmelCase     =  destination.setdefault(_lowerCAmelCase ,    {}						)
																		merge_dicts(_lowerCAmelCase ,    _lowerCAmelCase						)
												else:
																		__lowerCAmelCase     =  value

						return destination



def  lowercase     (_lowerCAmelCase = None						):
						if port is None:
												__lowerCAmelCase     =  2_9500
						with socket.socket(socket.AF_INET ,    socket.SOCK_STREAM						) as s:
												return s.connect_ex(("""localhost""", port)						) == 0
