
'''simple docstring'''







import torch
from torch import autograd







class 		snake_case_       (						autograd.Function						):



   """simple docstring"""





   @staticmethod
   def     __UpperCAmelCase      ( UpperCamelCase			,   UpperCamelCase			,   UpperCamelCase			,   UpperCamelCase):
          lowerCamelCase__				   =      inputs.numel()
          lowerCamelCase__				   =      int(0.0_0_5 * nb_elems) + 1
          if sigmoid:
                 lowerCamelCase__				   =      (torch.sigmoid(_A) > threshold).type(inputs.type())
          else:
                 lowerCamelCase__				   =      (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
                 lowerCamelCase__				   =      inputs.flatten().kthvalue(max(nb_elems - nb_min			,   1)).values
                 lowerCamelCase__				   =      (inputs > k_threshold).type(inputs.type())
          return mask







   @staticmethod
   def     __UpperCAmelCase      ( UpperCamelCase			,   UpperCamelCase):
          return gradOutput, None, None







class 		snake_case_       (						autograd.Function						):



   """simple docstring"""





   @staticmethod
   def     __UpperCAmelCase      ( UpperCamelCase			,   UpperCamelCase			,   UpperCamelCase):
          lowerCamelCase__				   =      inputs.clone()
          lowerCamelCase__				   =      inputs.flatten().sort(descending=_A)
          lowerCamelCase__				   =      int(threshold * inputs.numel())

          # flat_out and mask access the same memory.
          lowerCamelCase__				   =      mask.flatten()
          lowerCamelCase__				   =      0
          lowerCamelCase__				   =      1
          return mask







   @staticmethod
   def     __UpperCAmelCase      ( UpperCamelCase			,   UpperCamelCase):
          return gradOutput, None







class 		snake_case_       (						A__						):



   """simple docstring"""





   @staticmethod
   def     __UpperCAmelCase      ( UpperCamelCase			,   UpperCamelCase):
          lowerCamelCase__				   =      inputs.clone()
          lowerCamelCase__				   =      inputs.abs().flatten().sort(descending=_A)
          lowerCamelCase__				   =      int(threshold * inputs.numel())

          # flat_out and mask access the same memory.
          lowerCamelCase__				   =      mask.flatten()
          lowerCamelCase__				   =      0
          lowerCamelCase__				   =      1
          return mask






def 						snake_case__							(       __lowercase = 1_0_0_0							)		->		int:







						"""simple docstring"""

						A__						:				int         =			0
						A__						:				Optional[int]         =			0
						while 1:
												num += 3
												if num >= n:
																		break
												total += num
												num += 2
												if num >= n:
																		break
												total += num
												num += 1
												if num >= n:
																		break
												total += num
												num += 3
												if num >= n:
																		break
												total += num
												num += 1
												if num >= n:
																		break
												total += num
												num += 2
												if num >= n:
																		break
												total += num
												num += 3
												if num >= n:
																		break
												total += num
						return total


if __name__ == "__main__":
		print(f"""{solution() = }""")