def _compute_n_patches(i_h, i_w, p_h, p_w, max_patches=None):
 n_h = ((i_h - p_h) + 1)
 n_w = ((i_w - p_w) + 1)
 all_patches = (n_h * n_w)
 if max_patches:
  if (isinstance(max_patches, numbers.Integral) and (max_patches < all_patches)):
   return max_patches
  elif (isinstance(max_patches, numbers.Real) and (0 < max_patches < 1)):
   return int((max_patches * all_patches))
  else:
   raise ValueError(('Invalid value for max_patches: %r' % max_patches))
 else:
  return all_patches

def _compute_n_patches ( i_h , i_w , p_h , p_w , max_patches = None ) : n_h = ( ( i_h - p_h ) + 1 ) n_w = ( ( i_w - p_w ) + 1 ) all_patches = ( n_h * n_w ) if max_patches : if ( isinstance ( max_patches , numbers . Integral ) and ( max_patches < all_patches ) ) : return max_patches elif ( isinstance ( max_patches , numbers . Real ) and ( 0 < max_patches < 1 ) ) : return int ( ( max_patches * all_patches ) ) else : raise ValueError ( ( 'Invalid value for max_patches: %r' % max_patches ) ) else : return all_patches
compute the number of patches that will be extracted in an image .