




'''simple docstring'''





def       __a      (  _UpperCamelCase:       List[Any]   ,		_UpperCamelCase:       Optional[Any]   ,		_UpperCamelCase:       Optional[Any]   ,		_UpperCamelCase:       List[str]   ,		_UpperCamelCase:       Optional[int]   ,		_UpperCamelCase:       List[Any]       )		->					int:

     """simple docstring"""




     if index == r:
          for j in range(_UpperCamelCase       ):
               print(data[j]   ,		end=" "       )
          print(" "       )
          return
     #  When no more elements are there to put in data[]
     if i >= n:
          return
     # current is included, put next at next location
     _snake_case				= arr[i]
     combination_util(_UpperCamelCase   ,		_UpperCamelCase   ,		_UpperCamelCase   ,		index + 1   ,		_UpperCamelCase   ,		i + 1       )
     # current is excluded, replace it with
     # next (Note that i+1 is passed, but
     # index is not changed)
     combination_util(_UpperCamelCase   ,		_UpperCamelCase   ,		_UpperCamelCase   ,		_UpperCamelCase   ,		_UpperCamelCase   ,		i + 1       )
     # The main function that prints all combinations
     # of size r in arr[] of size n. This function
     # mainly uses combinationUtil()





def       __a      (  _UpperCamelCase:       Dict   ,		_UpperCamelCase:       List[Any]   ,		_UpperCamelCase:       Optional[Any]       )		->					str:

     """simple docstring"""




     _snake_case				= [0] * r
     # Print all combination using temporary array 'data[]'
     combination_util(_UpperCamelCase   ,		_UpperCamelCase   ,		_UpperCamelCase   ,		0   ,		_UpperCamelCase   ,		0       )


if __name__ == "__main__":
   # Driver code to check the function above
   UpperCamelCase_		:     List[Any]          =		[10, 20, 30, 40, 50]
   print_combination(arr, len(arr), 3)
   # This code is contributed by Ambuj sahu








'''simple docstring'''





import re

from flax.core.frozen_dict import freeze
from flax.traverse_util import flatten_dict, unflatten_dict
from jax.experimental import PartitionSpec as P


# Sentinels
UpperCamelCase_		:     Optional[int]          =		object()

# For specifying empty leaf dict `{}`
UpperCamelCase_		:     Optional[int]          =		object()





def       __a      (  _UpperCamelCase:       Union[str, Any]   ,		_UpperCamelCase:       Optional[Any]       )		->					Optional[Any]:

     """simple docstring"""




     _snake_case				= tuple((re.compile(x + "$"       ) for x in qs)       )
     for i in range(len(_UpperCamelCase       ) - len(_UpperCamelCase       ) + 1       ):
          _snake_case				= [x.match(_UpperCamelCase       ) for x, y in zip(_UpperCamelCase   ,		ks[i:]       )]
          if matches and all(_UpperCamelCase       ):
               return True
     return False





def       __a      (  _UpperCamelCase:       Optional[Any]       )		->					Union[str, Any]:

     """simple docstring"""




     def replace(_UpperCamelCase:       Tuple   ,		_UpperCamelCase:       List[str]       ):
          for rule, replacement in rules:
               if _match(_UpperCamelCase   ,		_UpperCamelCase       ):
                    return replacement
          return val

     return replace





def       __a      (  )		->					Any:

     """simple docstring"""




     return [
         # embeddings
         (("transformer", "wpe", "embedding"), P("mp"   ,		_UpperCamelCase       )),
         (("transformer", "wte", "embedding"), P("mp"   ,		_UpperCamelCase       )),
         # atention
         (("attention", "(q_proj|k_proj|v_proj)", "kernel"), P(_UpperCamelCase   ,		"mp"       )),
         (("attention", "out_proj", "kernel"), P("mp"   ,		_UpperCamelCase       )),
         (("attention", "out_proj", "bias"), None),
         # mlp
         (("mlp", "c_fc", "kernel"), P(_UpperCamelCase   ,		"mp"       )),
         (("mlp", "c_fc", "bias"), P("mp"       )),
         (("mlp", "c_proj", "kernel"), P("mp"   ,		_UpperCamelCase       )),
         (("mlp", "c_proj", "bias"), None),
         # layer norms
         ((r"ln_\d+", "bias"), None),
         ((r"\d+", r"ln_\d+", "scale"), None),
         (("ln_f", "bias"), None),
         (("ln_f", "scale"), None),
     ]





def       __a      (  _UpperCamelCase:       Union[str, Any]       )		->					Any:

     """simple docstring"""




     _snake_case				= _get_partition_rules()
     _snake_case				= _replacement_rules(_UpperCamelCase       )
     _snake_case				= {k: _unmatched for k in flatten_dict(_UpperCamelCase       )}
     _snake_case				= {k: replace(_UpperCamelCase   ,		_UpperCamelCase       ) for k, v in initd.items()}
     assert _unmatched not in result.values(), "Incomplete partition spec."
     return freeze(unflatten_dict(_UpperCamelCase       )       )


