






"""simple docstring"""


_UpperCamelCase :    Optional[Any]      =			[
    [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
]




def 					a			(  UpperCamelCase_				:					int  ,						UpperCamelCase_				:					int  ,						UpperCamelCase_				:					int  ,						UpperCamelCase_				:					int		)	->		bool:
 return 0 <= row < rows and 0 <= col < cols




def 					a			(  UpperCamelCase_				:					int  ,						UpperCamelCase_				:					int  ,						UpperCamelCase_				:					set  ,						UpperCamelCase_				:					list[list[int]]		)	->		int:
 __A						:							Tuple      =						len(UpperCamelCase_		)
 __A						:							int      =						len(mat[0]		)
 if is_safe(UpperCamelCase_  ,						UpperCamelCase_  ,						UpperCamelCase_  ,						UpperCamelCase_		) and (row, col) not in seen and mat[row][col] == 1:
  seen.add((row, col)		)
  return (
      1
      + depth_first_search(row + 1  ,						UpperCamelCase_  ,						UpperCamelCase_  ,						UpperCamelCase_		)
      + depth_first_search(row - 1  ,						UpperCamelCase_  ,						UpperCamelCase_  ,						UpperCamelCase_		)
      + depth_first_search(UpperCamelCase_  ,						col + 1  ,						UpperCamelCase_  ,						UpperCamelCase_		)
      + depth_first_search(UpperCamelCase_  ,						col - 1  ,						UpperCamelCase_  ,						UpperCamelCase_		)
  )
 else:
  return 0




def 					a			(  UpperCamelCase_				:					list[list[int]]		)	->		int:
 __A						:							set      =						set()

 __A						:							Optional[int]      =						0
 for row, line in enumerate(UpperCamelCase_		):
  for col, item in enumerate(UpperCamelCase_		):
   if item == 1 and (row, col) not in seen:
    # Maximizing the area
    __A						:							Dict      =						max(UpperCamelCase_  ,						depth_first_search(UpperCamelCase_  ,						UpperCamelCase_  ,						UpperCamelCase_  ,						UpperCamelCase_		)		)
 return max_area


if __name__ == "__main__":
   import doctest

   print(find_max_area(matrix))  # Output -> 6
   doctest.testmod()













"""simple docstring"""


import torch
from torch import autograd






class __a ( autograd.Function					):



  @staticmethod
  def     A_					(lowercase_	:		Optional[Any]					,      lowercase_	:		torch.tensor					,      lowercase_	:		float					,      lowercase_	:		bool )		->				List[str]:
   __A						:							str      =						inputs.numel()
   __A						:							str      =						int(0.005 * nb_elems ) + 1
   if sigmoid:
    __A						:							Dict      =						(torch.sigmoid(lowercase_ ) > threshold).type(inputs.type() )
   else:
    __A						:							Tuple      =						(inputs > threshold).type(inputs.type() )
   if mask.sum() < nb_min:
    # We limit the pruning so that at least 0.5% (half a percent) of the weights are remaining
    __A						:							Any      =						inputs.flatten().kthvalue(max(nb_elems - nb_min					,      1 ) ).values
    __A						:							Union[str, Any]      =						(inputs > k_threshold).type(inputs.type() )
   return mask



  @staticmethod
  def     A_					(lowercase_	:		str					,      lowercase_	:		Any )		->				int:
   return gradOutput, None, None






class __a ( autograd.Function					):



  @staticmethod
  def     A_					(lowercase_	:		List[Any]					,      lowercase_	:		torch.tensor					,      lowercase_	:		float )		->				Dict:
   __A						:							List[Any]      =						inputs.clone()
   __A     ,       __A						:							Optional[int]      =						inputs.flatten().sort(descending=lowercase_ )
   __A						:							Tuple      =						int(threshold * inputs.numel() )

   # flat_out and mask access the same memory.
   __A						:							Optional[Any]      =						mask.flatten()
   __A						:							Dict      =						0
   __A						:							Any      =						1
   return mask



  @staticmethod
  def     A_					(lowercase_	:		Tuple					,      lowercase_	:		Optional[Any] )		->				str:
   return gradOutput, None






class __a ( snake_case_					):



  @staticmethod
  def     A_					(lowercase_	:		torch.tensor					,      lowercase_	:		float )		->				List[str]:
   __A						:							List[str]      =						inputs.clone()
   __A     ,       __A						:							List[Any]      =						inputs.abs().flatten().sort(descending=lowercase_ )
   __A						:							Dict      =						int(threshold * inputs.numel() )

   # flat_out and mask access the same memory.
   __A						:							List[Any]      =						mask.flatten()
   __A						:							Dict      =						0
   __A						:							Tuple      =						1
   return mask





