



"""simple docstring"""

# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import doctest
import sys
import warnings
from os.path import abspath, dirname, join

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
a_			   =					abspath(join(dirname(__file__), '''src'''))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='''ignore''', category=FutureWarning)







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  Dict			):



					"""simple docstring"""





					config.addinivalue_line(
					    """markers"""				,    """is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested"""			)
					config.addinivalue_line(
					    """markers"""				,    """is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested"""			)
					config.addinivalue_line("""markers"""				,    """is_pipeline_test: mark test to run only when pipelines are tested"""			)
					config.addinivalue_line("""markers"""				,    """is_staging_test: mark test to run only in the staging environment"""			)
					config.addinivalue_line("""markers"""				,    """accelerate_tests: mark test that require accelerate"""			)
					config.addinivalue_line("""markers"""				,    """tool_tests: mark the tool tests that are run on their specific schedule"""			)







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  Optional[Any]			):



					"""simple docstring"""





					from transformers.testing_utils import pytest_addoption_shared

					pytest_addoption_shared(SCREAMING_SNAKE_CASE__			)







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  Optional[int]			):



					"""simple docstring"""





					from transformers.testing_utils import pytest_terminal_summary_main

					snake_case_					:		int 					=					terminalreporter.config.getoption("""--make-reports"""			)
					if make_reports:
										pytest_terminal_summary_main(SCREAMING_SNAKE_CASE__				,    id=SCREAMING_SNAKE_CASE__			)







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  str				,    SCREAMING_SNAKE_CASE__ :  Dict			):



					"""simple docstring"""





					if exitstatus == 5:
										snake_case_					:		List[Any] 					=					0


# Doctest custom flag to ignore output.
a_			   =					doctest.register_optionflag('''IGNORE_RESULT''')

a_			   =					doctest.OutputChecker







class    __lowercase     (					_UpperCAmelCase):







						"""simple docstring"""







						def 						__UpperCamelCase							(self   ,		lowercase__   ,		lowercase__   ,		lowercase__       ):
											if IGNORE_RESULT & optionflags:
																return True
											return OutputChecker.check_output(self   ,		lowercase__   ,		lowercase__   ,		lowercase__       )
a_			   =					CustomOutputChecker
a_			   =					HfDoctestModule


a_			   =					HfDocTestParser









"""simple docstring"""

from copy import deepcopy







class    __lowercase     :







						"""simple docstring"""







						def __init__(self   ,		lowercase__ = None   ,		lowercase__ = None       ):

											if arr is None and size is not None:
																snake_case_					:		str 					=					size
																snake_case_					:		Optional[Any] 					=					[0] * size
											elif arr is not None:
																self.init(lowercase__       )
											else:
																raise ValueError("""Either arr or size must be specified"""       )







						def 						__UpperCamelCase							(self   ,		lowercase__       ):
											snake_case_					:		Optional[Any] 					=					len(lowercase__       )
											snake_case_					:		int 					=					deepcopy(lowercase__       )
											for i in range(1   ,		self.size       ):
																snake_case_					:		Optional[Any] 					=					self.next_(lowercase__       )
																if j < self.size:
																					self.tree[j] += self.tree[i]







						def 						__UpperCamelCase							(self       ):
											snake_case_					:		Dict 					=					self.tree[:]
											for i in range(self.size - 1   ,		0   ,		-1       ):
																snake_case_					:		Optional[int] 					=					self.next_(lowercase__       )
																if j < self.size:
																					arr[j] -= arr[i]
											return arr







						@staticmethod
						def 						__UpperCamelCase							(lowercase__       ):
											return index + (index & (-index))







						@staticmethod
						def 						__UpperCamelCase							(lowercase__       ):
											return index - (index & (-index))







						def 						__UpperCamelCase							(self   ,		lowercase__   ,		lowercase__       ):
											if index == 0:
																self.tree[0] += value
																return
											while index < self.size:
																self.tree[index] += value
																snake_case_					:		Tuple 					=					self.next_(lowercase__       )







						def 						__UpperCamelCase							(self   ,		lowercase__   ,		lowercase__       ):
											self.add(lowercase__   ,		value - self.get(lowercase__       )       )







						def 						__UpperCamelCase							(self   ,		lowercase__       ):
											if right == 0:
																return 0
											snake_case_					:		List[str] 					=					self.tree[0]
											right -= 1  # make right inclusive
											while right > 0:
																result += self.tree[right]
																snake_case_					:		Optional[int] 					=					self.prev(lowercase__       )
											return result







						def 						__UpperCamelCase							(self   ,		lowercase__   ,		lowercase__       ):
											return self.prefix(lowercase__       ) - self.prefix(lowercase__       )







						def 						__UpperCamelCase							(self   ,		lowercase__       ):
											return self.query(lowercase__   ,		index + 1       )







						def 						__UpperCamelCase							(self   ,		lowercase__       ):
											value -= self.tree[0]
											if value < 0:
																return -1

											snake_case_					:		Tuple 					=					1  # Largest power of 2 <= size
											while j * 2 < self.size:
																j *= 2

											snake_case_					:		Tuple 					=					0

											while j > 0:
																if i + j < self.size and self.tree[i + j] <= value:
																					value -= self.tree[i + j]
																					i += j
																j //= 2
											return i


if __name__ == "__main__":
			import doctest

			doctest.testmod()




