code: 
  
  
  
  
  
  import numpy as np
  def   _A (	SCREAMING_SNAKE_CASE  :     Any , SCREAMING_SNAKE_CASE  :     Union[str, Any] , SCREAMING_SNAKE_CASE  :     List[Any]		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__			:      Optional[int]            =n_draws * class_counts / class_counts.sum()
    # floored means we don't overshoot n_samples, but probably undershoot
    a__			:      Any            =np.floor(SCREAMING_SNAKE_CASE		)
    # we add samples according to how much "left over" probability
    # they had, until we arrive at n_samples
    a__			:      int            =int(n_draws - floored.sum()		)
    if need_to_add > 0:
      a__			:      Any            =continuous - floored
      a__			:      Any            =np.sort(np.unique(SCREAMING_SNAKE_CASE		)		)[::-1]
      # add according to remainder, but break ties
      # randomly to avoid biases
      for value in values:
        ((a__)      ,							)			:      Dict            =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
        a__			:      str            =min(len(SCREAMING_SNAKE_CASE		) , SCREAMING_SNAKE_CASE		)
        a__			:      str            =rng.choice(SCREAMING_SNAKE_CASE , size=SCREAMING_SNAKE_CASE , replace=SCREAMING_SNAKE_CASE		)
        floored[inds] += 1
        need_to_add -= add_now
        if need_to_add == 0:
          break
    return floored.astype(np.intaa		)
  
  
  
  
  
  def   _A (	SCREAMING_SNAKE_CASE  :     Optional[int] , SCREAMING_SNAKE_CASE  :     Tuple , SCREAMING_SNAKE_CASE  :     List[Any] , SCREAMING_SNAKE_CASE  :     Optional[Any] , SCREAMING_SNAKE_CASE  :     List[str]=10		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__      ,							a__			:      List[Any]            =np.unique(SCREAMING_SNAKE_CASE , return_inverse=SCREAMING_SNAKE_CASE		)
    a__			:      str            =classes.shape[0]
    a__			:      Any            =np.bincount(SCREAMING_SNAKE_CASE		)
    if np.min(SCREAMING_SNAKE_CASE		) < 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)		)
    a__			:      List[str]            =np.split(np.argsort(SCREAMING_SNAKE_CASE , kind="mergesort"		) , np.cumsum(SCREAMING_SNAKE_CASE		)[:-1]		)
    for _ in range(SCREAMING_SNAKE_CASE		):
      a__			:      Any            =approximate_mode(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
      a__			:      Optional[int]            =class_counts - n_i
      a__			:      Optional[int]            =approximate_mode(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
  
      a__			:      Tuple            =[]
      a__			:      Optional[Any]            =[]
  
      for i in range(SCREAMING_SNAKE_CASE		):
        a__			:      List[str]            =rng.permutation(class_counts[i]		)
        a__			:      int            =class_indices[i].take(SCREAMING_SNAKE_CASE , 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]]		)
      a__			:      Dict            =rng.permutation(SCREAMING_SNAKE_CASE		)
      a__			:      Tuple            =rng.permutation(SCREAMING_SNAKE_CASE		)
  
      yield train, test
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  def   _A (	SCREAMING_SNAKE_CASE  :     int		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		) or number < 0:
      raise ValueError("Input must be a non-negative integer"		)
  
    a__			:      List[str]            =number & ~(number - 1)
    a__			:      Optional[int]            =0
    while intermediate:
      intermediate >>= 1
      index += 1
    return index - 1
  
  
  if __name__ == "__main__":
       import doctest
  
       doctest.testmod(verbose=True)
  
  
  
  
  
  
  