





import argparse
import os
import re


_UpperCamelCase							=      'src/diffusers'

# Pattern that looks at the indentation in a line.
_UpperCamelCase							=      re.compile(r'^(\s*)\S')
# Pattern that matches `"key":" and puts `key` in group 0.
_UpperCamelCase							=      re.compile(r'^\s*"([^"]+)":')
# Pattern that matches `_import_structure["key"]` and puts `key` in group 0.
_UpperCamelCase							=      re.compile(r'^\s*_import_structure\["([^"]+)"\]')
# Pattern that matches `"key",` and puts `key` in group 0.
_UpperCamelCase							=      re.compile(r'^\s*"([^"]+)",\s*$')
# Pattern that matches any `[stuff]` and puts `stuff` in group 0.
_UpperCamelCase							=      re.compile(r'\[([^\]]+)\]')



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							List[Any]   ):


							'''simple docstring'''







							__lowerCamelCase      :      Union[str, Any]         =_re_indent.search(SCREAMING_SNAKE_CASE   )
							return "" if search is None else search.groups()[0]



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							str    ,						SCREAMING_SNAKE_CASE       :							List[Any]=""    ,						SCREAMING_SNAKE_CASE       :							List[Any]=None    ,						SCREAMING_SNAKE_CASE       :							List[Any]=None   ):


							'''simple docstring'''







							__lowerCamelCase      :      List[str]         =0
							__lowerCamelCase      :      Optional[Any]         =code.split('''\n'''   )
							if start_prompt is not None:
														while not lines[index].startswith(SCREAMING_SNAKE_CASE   ):
																					index += 1
														__lowerCamelCase      :      List[str]         =['''\n'''.join(lines[:index]   )]
							else:
														__lowerCamelCase      :      str         =[]

							# We split into blocks until we get to the `end_prompt` (or the end of the block).
							__lowerCamelCase      :      Optional[int]         =[lines[index]]
							index += 1
							while index < len(SCREAMING_SNAKE_CASE   ) and (end_prompt is None or not lines[index].startswith(SCREAMING_SNAKE_CASE   )):
														if len(lines[index]   ) > 0 and get_indent(lines[index]   ) == indent_level:
																					if len(SCREAMING_SNAKE_CASE   ) > 0 and get_indent(current_block[-1]   ).startswith(indent_level + ''' '''   ):
																												current_block.append(lines[index]   )
																												blocks.append('''\n'''.join(SCREAMING_SNAKE_CASE   )   )
																												if index < len(SCREAMING_SNAKE_CASE   ) - 1:
																																			__lowerCamelCase      :      Dict         =[lines[index + 1]]
																																			index += 1
																												else:
																																			__lowerCamelCase      :      Union[str, Any]         =[]
																					else:
																												blocks.append('''\n'''.join(SCREAMING_SNAKE_CASE   )   )
																												__lowerCamelCase      :      Dict         =[lines[index]]
														else:
																					current_block.append(lines[index]   )
														index += 1

							# Adds current block if it's nonempty.
							if len(SCREAMING_SNAKE_CASE   ) > 0:
														blocks.append('''\n'''.join(SCREAMING_SNAKE_CASE   )   )

							# Add final block after end_prompt if provided.
							if end_prompt is not None and index < len(SCREAMING_SNAKE_CASE   ):
														blocks.append('''\n'''.join(lines[index:]   )   )

							return blocks



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							Union[str, Any]   ):


							'''simple docstring'''







							def _inner(SCREAMING_SNAKE_CASE       :							Any   ):
														return key(SCREAMING_SNAKE_CASE   ).lower().replace('''_'''    ,						''''''   )

							return _inner



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							Optional[Any]    ,						SCREAMING_SNAKE_CASE       :							Optional[Any]=None   ):


							'''simple docstring'''







							def noop(SCREAMING_SNAKE_CASE       :							Union[str, Any]   ):
														return x

							if key is None:
														__lowerCamelCase      :      int         =noop
							# Constants are all uppercase, they go first.
							__lowerCamelCase      :      Optional[Any]         =[obj for obj in objects if key(SCREAMING_SNAKE_CASE   ).isupper()]
							# Classes are not all uppercase but start with a capital, they go second.
							__lowerCamelCase      :      List[str]         =[obj for obj in objects if key(SCREAMING_SNAKE_CASE   )[0].isupper() and not key(SCREAMING_SNAKE_CASE   ).isupper()]
							# Functions begin with a lowercase, they go last.
							__lowerCamelCase      :      Optional[Any]         =[obj for obj in objects if not key(SCREAMING_SNAKE_CASE   )[0].isupper()]

							__lowerCamelCase      :      str         =ignore_underscore(SCREAMING_SNAKE_CASE   )
							return sorted(SCREAMING_SNAKE_CASE    ,						key=SCREAMING_SNAKE_CASE   ) + sorted(SCREAMING_SNAKE_CASE    ,						key=SCREAMING_SNAKE_CASE   ) + sorted(SCREAMING_SNAKE_CASE    ,						key=SCREAMING_SNAKE_CASE   )



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							Union[str, Any]   ):


							'''simple docstring'''







							def _replace(SCREAMING_SNAKE_CASE       :							Optional[int]   ):
														__lowerCamelCase      :      Any         =match.groups()[0]
														if "," not in imports:
																					return F'[{imports}]'
														__lowerCamelCase      :      Dict         =[part.strip().replace('''"'''    ,						''''''   ) for part in imports.split(''','''   )]
														# We will have a final empty element if the line finished with a comma.
														if len(keys[-1]   ) == 0:
																					__lowerCamelCase      :      Optional[Any]         =keys[:-1]
														return "[" + ", ".join([F'"{k}"' for k in sort_objects(SCREAMING_SNAKE_CASE   )]   ) + "]"

							__lowerCamelCase      :      Optional[int]         =import_statement.split('''\n'''   )
							if len(SCREAMING_SNAKE_CASE   ) > 3:
														# Here we have to sort internal imports that are on several lines (one per name):
														# key: [
														#     "object1",
														#     "object2",
														#     ...
														# ]

														# We may have to ignore one or two lines on each side.
														__lowerCamelCase      :      List[Any]         =2 if lines[1].strip() == '''[''' else 1
														__lowerCamelCase      :      Optional[int]         =[(i, _re_strip_line.search(SCREAMING_SNAKE_CASE   ).groups()[0]) for i, line in enumerate(lines[idx:-idx]   )]
														__lowerCamelCase      :      int         =sort_objects(SCREAMING_SNAKE_CASE    ,						key=lambda SCREAMING_SNAKE_CASE   : x[1]   )
														__lowerCamelCase      :      Dict         =[lines[x[0] + idx] for x in sorted_indices]
														return "\n".join(lines[:idx] + sorted_lines + lines[-idx:]   )
							elif len(SCREAMING_SNAKE_CASE   ) == 3:
														# Here we have to sort internal imports that are on one separate line:
														# key: [
														#     "object1", "object2", ...
														# ]
														if _re_bracket_content.search(lines[1]   ) is not None:
																					__lowerCamelCase      :      Union[str, Any]         =_re_bracket_content.sub(_replace    ,						lines[1]   )
														else:
																					__lowerCamelCase      :      List[Any]         =[part.strip().replace('''"'''    ,						''''''   ) for part in lines[1].split(''','''   )]
																					# We will have a final empty element if the line finished with a comma.
																					if len(keys[-1]   ) == 0:
																												__lowerCamelCase      :      Dict         =keys[:-1]
																					__lowerCamelCase      :      Any         =get_indent(lines[1]   ) + ''', '''.join([F'"{k}"' for k in sort_objects(SCREAMING_SNAKE_CASE   )]   )
														return "\n".join(SCREAMING_SNAKE_CASE   )
							else:
														# Finally we have to deal with imports fitting on one line
														__lowerCamelCase      :      Tuple         =_re_bracket_content.sub(_replace    ,						SCREAMING_SNAKE_CASE   )
														return import_statement



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							Tuple    ,						SCREAMING_SNAKE_CASE       :							Union[str, Any]=True   ):


							'''simple docstring'''







							with open(SCREAMING_SNAKE_CASE    ,						'''r'''   ) as f:
														__lowerCamelCase      :      Any         =f.read()

							if "_import_structure" not in code:
														return

							# Blocks of indent level 0
							__lowerCamelCase      :      int         =split_code_in_indented_blocks(
							    SCREAMING_SNAKE_CASE    ,						start_prompt='''_import_structure = {'''    ,						end_prompt='''if TYPE_CHECKING:'''   )

							# We ignore block 0 (everything until start_prompt) and the last block (everything after end_prompt).
							for block_idx in range(1    ,						len(SCREAMING_SNAKE_CASE   ) - 1   ):
														# Check if the block contains some `_import_structure`s thingy to sort.
														__lowerCamelCase      :      Tuple         =main_blocks[block_idx]
														__lowerCamelCase      :      Union[str, Any]         =block.split('''\n'''   )

														# Get to the start of the imports.
														__lowerCamelCase      :      Tuple         =0
														while line_idx < len(SCREAMING_SNAKE_CASE   ) and "_import_structure" not in block_lines[line_idx]:
																					# Skip dummy import blocks
																					if "import dummy" in block_lines[line_idx]:
																												__lowerCamelCase      :      Optional[Any]         =len(SCREAMING_SNAKE_CASE   )
																					else:
																												line_idx += 1
														if line_idx >= len(SCREAMING_SNAKE_CASE   ):
																					continue

														# Ignore beginning and last line: they don't contain anything.
														__lowerCamelCase      :      List[Any]         ='''\n'''.join(block_lines[line_idx:-1]   )
														__lowerCamelCase      :      Dict         =get_indent(block_lines[1]   )
														# Slit the internal block into blocks of indent level 1.
														__lowerCamelCase      :      int         =split_code_in_indented_blocks(SCREAMING_SNAKE_CASE    ,						indent_level=SCREAMING_SNAKE_CASE   )
														# We have two categories of import key: list or _import_structure[key].append/extend
														__lowerCamelCase      :      Union[str, Any]         =_re_direct_key if '''_import_structure''' in block_lines[0] else _re_indirect_key
														# Grab the keys, but there is a trap: some lines are empty or just comments.
														__lowerCamelCase      :      str         =[(pattern.search(SCREAMING_SNAKE_CASE   ).groups()[0] if pattern.search(SCREAMING_SNAKE_CASE   ) is not None else None) for b in internal_blocks]
														# We only sort the lines with a key.
														__lowerCamelCase      :      Tuple         =[(i, key) for i, key in enumerate(SCREAMING_SNAKE_CASE   ) if key is not None]
														__lowerCamelCase      :      List[Any]         =[x[0] for x in sorted(SCREAMING_SNAKE_CASE    ,						key=lambda SCREAMING_SNAKE_CASE   : x[1]   )]

														# We reorder the blocks by leaving empty lines/comments as they were and reorder the rest.
														__lowerCamelCase      :      List[Any]         =0
														__lowerCamelCase      :      int         =[]
														for i in range(len(SCREAMING_SNAKE_CASE   )   ):
																					if keys[i] is None:
																												reordered_blocks.append(internal_blocks[i]   )
																					else:
																												__lowerCamelCase      :      Union[str, Any]         =sort_objects_in_import(internal_blocks[sorted_indices[count]]   )
																												reordered_blocks.append(SCREAMING_SNAKE_CASE   )
																												count += 1

        # And we put our main block back together with its first and last line.
														__lowerCamelCase      :      List[Any]         ='''\n'''.join(block_lines[:line_idx] + reordered_blocks + [block_lines[-1]]   )

							if code != "\n".join(SCREAMING_SNAKE_CASE   ):
														if check_only:
																					return True
														else:
																					print(F'Overwriting {file}.'   )
																					with open(SCREAMING_SNAKE_CASE    ,						'''w'''   ) as f:
																												f.write('''\n'''.join(SCREAMING_SNAKE_CASE   )   )



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							Tuple=True   ):


							'''simple docstring'''







							__lowerCamelCase      :      List[Any]         =[]
							for root, _, files in os.walk(SCREAMING_SNAKE_CASE   ):
														if "__init__.py" in files:
																					__lowerCamelCase      :      Dict         =sort_imports(os.path.join(SCREAMING_SNAKE_CASE    ,						'''__init__.py'''   )    ,						check_only=SCREAMING_SNAKE_CASE   )
																					if result:
																												__lowerCamelCase      :      Optional[int]         =[os.path.join(SCREAMING_SNAKE_CASE    ,						'''__init__.py'''   )]
							if len(SCREAMING_SNAKE_CASE   ) > 0:
														raise ValueError(F'Would overwrite {len(SCREAMING_SNAKE_CASE   )} files, run `make style`.'   )


if __name__ == "__main__":
							_UpperCamelCase							=      argparse.ArgumentParser()
							parser.add_argument('--check_only', action='store_true', help='Whether to only check or fix style.')
							_UpperCamelCase							=      parser.parse_args()

							sort_imports_in_all_inits(check_only=args.check_only)











"""simple docstring"""





import math
from datetime import datetime, timedelta



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							int   ):


							'''simple docstring'''







							__lowerCamelCase      :      Any         =year % 19
							__lowerCamelCase      :      Optional[Any]         =year % 4
							__lowerCamelCase      :      Tuple         =year % 7
							__lowerCamelCase      :      Optional[int]         =math.floor(year / 100   )
							__lowerCamelCase      :      List[str]         =math.floor((13 + 8 * leap_day_inhibits) / 25   )
							__lowerCamelCase      :      Any         =leap_day_inhibits / 4
							__lowerCamelCase      :      Optional[Any]         =(
							    15 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
							) % 30
							__lowerCamelCase      :      Optional[Any]         =(4 + leap_day_inhibits - leap_day_reinstall_number) % 7

							# days to be added to March 21
							__lowerCamelCase      :      Any         =(19 * metonic_cycle + secular_moon_shift) % 30

							# PHM -> Paschal Full Moon
							__lowerCamelCase      :      str         =(
							    2 * julian_leap_year
							    + 4 * non_leap_year
							    + 6 * days_to_add
							    + century_starting_point
							) % 7

							if days_to_add == 29 and days_from_phm_to_sunday == 6:
														return datetime(SCREAMING_SNAKE_CASE    ,						4    ,						19   )
							elif days_to_add == 28 and days_from_phm_to_sunday == 6:
														return datetime(SCREAMING_SNAKE_CASE    ,						4    ,						18   )
							else:
														return datetime(SCREAMING_SNAKE_CASE    ,						3    ,						22   ) + timedelta(
														    days=int(days_to_add + days_from_phm_to_sunday   )   )


if __name__ == "__main__":
							for year in (1994, 2000, 2010, 2021, 2023):
														_UpperCamelCase							=      'will be' if year > datetime.now().year else 'was'
														print(f'''Easter in {year} {tense} {gauss_easter(year)}''')




