code: 
  
  
  
  
  
  
  """simple docstring"""
  from typing import SupportsIndex
  
  import numpy as np
  from scipy.ndimage import convolve
  
  
  def        A	(							__snake_case:   np.ndarray   ,    __snake_case:   np.ndarray   ,    __snake_case:   np.ndarray     )						->		np.ndarray:
  
         """simple docstring"""
  
  
  
  
  
         __magic_name__										=						np.stack((horizontal_flow, vertical_flow)   ,    2     )
  
         # Create a grid of all pixel coordinates and subtract the flow to get the
         # target pixels coordinates
         __magic_name__										=						np.stack(
             np.meshgrid(np.arange(0   ,    image.shape[1]     )   ,    np.arange(0   ,    image.shape[0]     )     )   ,    2     )
         __magic_name__										=						np.round(grid - flow     ).astype(np.intaa     )
  
         # Find the locations outside of the original image
         __magic_name__										=						(grid < 0) | (grid >= np.array([image.shape[1], image.shape[0]]     ))
         __magic_name__										=						0
  
         __magic_name__										=						image[grid[:, :, 1], grid[:, :, 0]]
  
         # Set pixels at invalid locations to 0
         __magic_name__										=						0
  
         return warped
  
  
  def        A	(							__snake_case:   np.ndarray   ,    __snake_case:   np.ndarray   ,    __snake_case:   SupportsIndex   ,    __snake_case:   float | None = None   ,    )						->		tuple[np.ndarray, np.ndarray]:
  
         """simple docstring"""
  
  
  
  
  
         if alpha is None:
                __magic_name__										=						0.1
  
         # Initialize flow
         __magic_name__										=						np.zeros_like(a_     )
         __magic_name__										=						np.zeros_like(a_     )
  
         # Prepare kernels for the calculation of the derivatives and the average velocity
         __magic_name__										=						np.array([[-1, 1], [-1, 1]]     ) * 0.25
         __magic_name__										=						np.array([[-1, -1], [1, 1]]     ) * 0.25
         __magic_name__										=						np.array([[1, 1], [1, 1]]     ) * 0.25
         __magic_name__										=						np.array(
             [[1 / 1_2, 1 / 6, 1 / 1_2], [1 / 6, 0, 1 / 6], [1 / 1_2, 1 / 6, 1 / 1_2]]     )
  
         # Iteratively refine the flow
         for _ in range(a_     ):
                __magic_name__										=						warp(a_   ,    a_   ,    a_     )
                __magic_name__										=						convolve(a_   ,    a_     ) + convolve(a_   ,    a_     )
                __magic_name__										=						convolve(a_   ,    a_     ) + convolve(a_   ,    a_     )
                __magic_name__										=						convolve(a_   ,    a_     ) + convolve(a_   ,    -kernel_t     )
  
                __magic_name__										=						convolve(a_   ,    a_     )
                __magic_name__										=						convolve(a_   ,    a_     )
  
                # This updates the flow as proposed in the paper (Step 12)
                __magic_name__										=						(
                    derivative_x * avg_horizontal_velocity
                    + derivative_y * avg_vertical_velocity
                    + derivative_t
                )
                __magic_name__										=						update / (alpha**2 + derivative_x**2 + derivative_y**2)
  
                __magic_name__										=						avg_horizontal_velocity - derivative_x * update
                __magic_name__										=						avg_vertical_velocity - derivative_y * update
  
         return horizontal_flow, vertical_flow
  
  
  if __name__ == "__main__":
   import doctest
  
   doctest.testmod()
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  import numpy as np
  
  
  def        A	(							__snake_case:   Any   ,    __snake_case:   List[str]   ,    __snake_case:   Tuple     )						->		Dict:
  
         """simple docstring"""
  
  
  
  
  
         __magic_name__										=						n_draws * class_counts / class_counts.sum()
         # floored means we don't overshoot n_samples, but probably undershoot
         __magic_name__										=						np.floor(__snake_case     )
         # we add samples according to how much "left over" probability
         # they had, until we arrive at n_samples
         __magic_name__										=						int(n_draws - floored.sum()     )
         if need_to_add > 0:
                __magic_name__										=						continuous - floored
                __magic_name__										=						np.sort(np.unique(__snake_case     )     )[::-1]
                # add according to remainder, but break ties
                # randomly to avoid biases
                for value in values:
                       ((__magic_name__)							,     )										=						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
                       __magic_name__										=						min(len(__snake_case     )   ,    __snake_case     )
                       __magic_name__										=						rng.choice(__snake_case   ,    size=__snake_case   ,    replace=__snake_case     )
                       floored[inds] += 1
                       need_to_add -= add_now
                       if need_to_add == 0:
                              break
         return floored.astype(np.intaa     )
  
  
  
  
  
  
  def        A	(							__snake_case:   Any   ,    __snake_case:   str   ,    __snake_case:   int   ,    __snake_case:   Optional[Any]   ,    __snake_case:   Any=1_0     )						->		Any:
  
         """simple docstring"""
  
  
  
  
  
         __magic_name__							,     __magic_name__										=						np.unique(__snake_case   ,    return_inverse=__snake_case     )
         __magic_name__										=						classes.shape[0]
         __magic_name__										=						np.bincount(__snake_case     )
         if np.min(__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)     )
         __magic_name__										=						np.split(np.argsort(__snake_case   ,    kind='mergesort'     )   ,    np.cumsum(__snake_case     )[:-1]     )
         for _ in range(__snake_case     ):
                __magic_name__										=						approximate_mode(__snake_case   ,    __snake_case   ,    __snake_case     )
                __magic_name__										=						class_counts - n_i
                __magic_name__										=						approximate_mode(__snake_case   ,    __snake_case   ,    __snake_case     )
  
                __magic_name__										=						[]
                __magic_name__										=						[]
  
                for i in range(__snake_case     ):
                       __magic_name__										=						rng.permutation(class_counts[i]     )
                       __magic_name__										=						class_indices[i].take(__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]]     )
                __magic_name__										=						rng.permutation(__snake_case     )
                __magic_name__										=						rng.permutation(__snake_case     )
  
                yield train, test