

'''simple docstring'''

import torch

from diffusers import LMSDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest





class 							_snake_case	(    _a  ):
   _A    :       Optional[int]      				=   (LMSDiscreteScheduler,)
   _A    :       List[Any]      				=   1_0
   def       __UpperCamelCase  (	self     : str       ,**SCREAMING_SNAKE_CASE__     : Union[str, Any]							):
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   {
         "num_train_timesteps": 1_100,
         "beta_start": 0.0_001,
         "beta_end": 0.02,
         "beta_schedule": "linear",
     }

     config.update(**SCREAMING_SNAKE_CASE__							)
     return config
   def       __UpperCamelCase  (	self     : Optional[Any]							):
     for timesteps in [10, 50, 100, 1_000]:
       self.check_over_configs(num_train_timesteps=SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : int							):
     for beta_start, beta_end in zip([0.00_001, 0.0_001, 0.001]       ,[0.0_002, 0.002, 0.02]							):
       self.check_over_configs(beta_start=SCREAMING_SNAKE_CASE__       ,beta_end=SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : List[str]							):
     for schedule in ["linear", "scaled_linear"]:
       self.check_over_configs(beta_schedule=SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : List[str]							):
     for prediction_type in ["epsilon", "v_prediction"]:
       self.check_over_configs(prediction_type=SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Dict							):
     for t in [0, 500, 800]:
       self.check_over_forward(time_step=SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Any							):
     SCREAMING_SNAKE_CASE:Optional[int]   =   self.scheduler_classes[0]
     SCREAMING_SNAKE_CASE:Optional[Any]   =   self.get_scheduler_config()
     SCREAMING_SNAKE_CASE:Any   =   scheduler_class(**SCREAMING_SNAKE_CASE__							)

     scheduler.set_timesteps(self.num_inference_steps							)

     SCREAMING_SNAKE_CASE:Tuple   =   self.dummy_model()
     SCREAMING_SNAKE_CASE:Tuple   =   self.dummy_sample_deter * scheduler.init_noise_sigma

     for i, t in enumerate(scheduler.timesteps							):
       SCREAMING_SNAKE_CASE:Union[str, Any]   =   scheduler.scale_model_input(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Any   =   model(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Optional[Any]   =   scheduler.step(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)
       SCREAMING_SNAKE_CASE:Any   =   output.prev_sample

     SCREAMING_SNAKE_CASE:Optional[int]   =   torch.sum(torch.abs(SCREAMING_SNAKE_CASE__							)							)
     SCREAMING_SNAKE_CASE:int   =   torch.mean(torch.abs(SCREAMING_SNAKE_CASE__							)							)

     assert abs(result_sum.item() - 1_006.388							) < 1e-2
     assert abs(result_mean.item() - 1.31							) < 1e-3
   def       __UpperCamelCase  (	self     : Dict							):
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   self.scheduler_classes[0]
     SCREAMING_SNAKE_CASE:Tuple   =   self.get_scheduler_config(prediction_type="v_prediction"							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   scheduler_class(**SCREAMING_SNAKE_CASE__							)

     scheduler.set_timesteps(self.num_inference_steps							)

     SCREAMING_SNAKE_CASE:Tuple   =   self.dummy_model()
     SCREAMING_SNAKE_CASE:str   =   self.dummy_sample_deter * scheduler.init_noise_sigma

     for i, t in enumerate(scheduler.timesteps							):
       SCREAMING_SNAKE_CASE:Tuple   =   scheduler.scale_model_input(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:str   =   model(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Optional[Any]   =   scheduler.step(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)
       SCREAMING_SNAKE_CASE:int   =   output.prev_sample

     SCREAMING_SNAKE_CASE:Dict   =   torch.sum(torch.abs(SCREAMING_SNAKE_CASE__							)							)
     SCREAMING_SNAKE_CASE:Tuple   =   torch.mean(torch.abs(SCREAMING_SNAKE_CASE__							)							)

     assert abs(result_sum.item() - 0.0_017							) < 1e-2
     assert abs(result_mean.item() - 2.2_676e-06							) < 1e-3
   def       __UpperCamelCase  (	self     : List[str]							):
     SCREAMING_SNAKE_CASE:Any   =   self.scheduler_classes[0]
     SCREAMING_SNAKE_CASE:str   =   self.get_scheduler_config()
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   scheduler_class(**SCREAMING_SNAKE_CASE__							)

     scheduler.set_timesteps(self.num_inference_steps       ,device=SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Optional[int]   =   self.dummy_model()
     SCREAMING_SNAKE_CASE:List[str]   =   self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
     SCREAMING_SNAKE_CASE:Optional[int]   =   sample.to(SCREAMING_SNAKE_CASE__							)

     for i, t in enumerate(scheduler.timesteps							):
       SCREAMING_SNAKE_CASE:Any   =   scheduler.scale_model_input(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Tuple   =   model(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Any   =   scheduler.step(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)
       SCREAMING_SNAKE_CASE:List[Any]   =   output.prev_sample

     SCREAMING_SNAKE_CASE:Optional[Any]   =   torch.sum(torch.abs(SCREAMING_SNAKE_CASE__							)							)
     SCREAMING_SNAKE_CASE:List[Any]   =   torch.mean(torch.abs(SCREAMING_SNAKE_CASE__							)							)

     assert abs(result_sum.item() - 1_006.388							) < 1e-2
     assert abs(result_mean.item() - 1.31							) < 1e-3







   def       __UpperCamelCase  (	self     : Any							):
     SCREAMING_SNAKE_CASE:Tuple   =   self.scheduler_classes[0]
     SCREAMING_SNAKE_CASE:List[Any]   =   self.get_scheduler_config()
     SCREAMING_SNAKE_CASE:List[Any]   =   scheduler_class(**SCREAMING_SNAKE_CASE__       ,use_karras_sigmas=SCREAMING_SNAKE_CASE__							)

     scheduler.set_timesteps(self.num_inference_steps       ,device=SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Tuple   =   self.dummy_model()
     SCREAMING_SNAKE_CASE:int   =   self.dummy_sample_deter.to(SCREAMING_SNAKE_CASE__							) * scheduler.init_noise_sigma
     SCREAMING_SNAKE_CASE:Dict   =   sample.to(SCREAMING_SNAKE_CASE__							)

     for t in scheduler.timesteps:
       SCREAMING_SNAKE_CASE:Optional[Any]   =   scheduler.scale_model_input(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Union[str, Any]   =   model(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)

       SCREAMING_SNAKE_CASE:Tuple   =   scheduler.step(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__							)
       SCREAMING_SNAKE_CASE:int   =   output.prev_sample

     SCREAMING_SNAKE_CASE:Optional[Any]   =   torch.sum(torch.abs(SCREAMING_SNAKE_CASE__							)							)
     SCREAMING_SNAKE_CASE:str   =   torch.mean(torch.abs(SCREAMING_SNAKE_CASE__							)							)

     assert abs(result_sum.item() - 3_812.9_927							) < 2e-2
     assert abs(result_mean.item() - 4.9_648							) < 1e-3









'''simple docstring'''

from collections import Counter





def 				A_					(	snake_case	):
  return sum(socks_by_color // 2 for socks_by_color in Counter(snake_case	).values()	)


if __name__ == "__main__":
    import doctest

    doctest.testmod()

    A_      =							[int(x) for x in input("Enter socks by color :").rstrip().split()]
    print(f'''sock_merchant({colors}) = {sock_merchant(colors)}''')






