from typing import Callable, Dict, Optional, Tuple

import torch
from torch import nn
from torch.distributions import (
    AffineTransform,
    Distribution,
    Independent,
    NegativeBinomial,
    Normal,
    StudentT,
    TransformedDistribution,
)
class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):







							def __init__(				self     :    Tuple	,					__snake_case     :    Distribution	,					__snake_case     :    Any=None	,					__snake_case     :    Any=None	,					__snake_case     :    List[Any]=0		):
										lowerCamelCase						:Dict						  =     1.0 if scale is None else scale
										lowerCamelCase						:Any						  =     0.0 if loc is None else loc

										super().__init__(__snake_case	,					[AffineTransform(loc=self.loc	,					scale=self.scale	,					event_dim=__snake_case		)]		)







							@property
							def 				snake_case  (				self     :    Optional[Any]		):
										return self.base_dist.mean * self.scale + self.loc







							@property
							def 				snake_case  (				self     :    Tuple		):
										return self.base_dist.variance * self.scale**2







							@property
							def 				snake_case  (				self     :    Dict		):
										return self.variance.sqrt()


class   _lowerCAmelCase		(     nn.Module				):







							def __init__(				self     :    str	,					__snake_case     :    int	,					__snake_case     :    Dict[str, int]	,					__snake_case     :    Callable[..., Tuple[torch.Tensor]]	,					**__snake_case     :    str		):
										super().__init__(**__snake_case		)
										lowerCamelCase						:List[Any]						  =     args_dim
										lowerCamelCase						:Any						  =     nn.ModuleList([nn.Linear(__snake_case	,					__snake_case		) for dim in args_dim.values()]		)
										lowerCamelCase						:Optional[int]						  =     domain_map







							def 				snake_case  (				self     :    int	,					__snake_case     :    torch.Tensor		):
										lowerCamelCase						:int						  =     [proj(__snake_case		) for proj in self.proj]

										return self.domain_map(*__snake_case		)


class   _lowerCAmelCase		(     nn.Module				):







							def __init__(				self     :    str	,					__snake_case     :    Optional[int]		):
										super().__init__()
										lowerCamelCase						:Union[str, Any]						  =     function







							def 				snake_case  (				self     :    List[str]	,					__snake_case     :    List[str]	,					*__snake_case     :    str		):
										return self.function(__snake_case	,					*__snake_case		)


class   _lowerCAmelCase		:
							_UpperCAmelCase						    =     42
							_UpperCAmelCase						    =     42
							_UpperCAmelCase						    =     42







							def __init__(				self     :    Tuple	,					__snake_case     :    int = 1		):
										lowerCamelCase						:Any						  =     dim
										lowerCamelCase						:Tuple						  =     {k: dim * self.args_dim[k] for k in self.args_dim}







							def 				snake_case  (				self     :    Optional[int]	,					__snake_case     :    List[str]		):
										if self.dim == 1:
													return self.distribution_class(*__snake_case		)
										else:
													return Independent(self.distribution_class(*__snake_case		)	,					1		)







							def 				snake_case  (				self     :    str	,					__snake_case     :    Tuple	,					__snake_case     :    Optional[torch.Tensor] = None	,					__snake_case     :    Optional[torch.Tensor] = None	,					):
										lowerCamelCase						:Dict						  =     self._base_distribution(__snake_case		)
										if loc is None and scale is None:
													return distr
										else:
													return AffineTransformed(__snake_case	,					loc=__snake_case	,					scale=__snake_case	,					event_dim=self.event_dim		)







							@property
							def 				snake_case  (				self     :    str		):
										return () if self.dim == 1 else (self.dim,)







							@property
							def 				snake_case  (				self     :    Any		):
										return len(self.event_shape		)







							@property
							def 				snake_case  (				self     :    Optional[Any]		):
										return 0.0







							def 				snake_case  (				self     :    Tuple	,					__snake_case     :    int		):
										return ParameterProjection(
										    in_features=__snake_case	,					args_dim=self.args_dim	,					domain_map=LambdaLayer(self.domain_map		)	,					)







							def 				snake_case  (				self     :    Optional[int]	,					*__snake_case     :    torch.Tensor		):
										raise NotImplementedError()







							@staticmethod
							def 				snake_case  (				__snake_case     :    torch.Tensor		):
										return (x + torch.sqrt(torch.square(__snake_case		) + 4.0		)) / 2.0


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     {"df": 1, "loc": 1, "scale": 1}
							_UpperCAmelCase						    =     StudentT







							@classmethod
							def 				snake_case  (				cls     :    Any	,					__snake_case     :    torch.Tensor	,					__snake_case     :    torch.Tensor	,					__snake_case     :    torch.Tensor		):
										lowerCamelCase						:List[str]						  =     cls.squareplus(__snake_case		).clamp_min(torch.finfo(scale.dtype		).eps		)
										lowerCamelCase						:Dict						  =     2.0 + cls.squareplus(__snake_case		)
										return df.squeeze(-1		), loc.squeeze(-1		), scale.squeeze(-1		)


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     {"loc": 1, "scale": 1}
							_UpperCAmelCase						    =     Normal







							@classmethod
							def 				snake_case  (				cls     :    Optional[int]	,					__snake_case     :    torch.Tensor	,					__snake_case     :    torch.Tensor		):
										lowerCamelCase						:Union[str, Any]						  =     cls.squareplus(__snake_case		).clamp_min(torch.finfo(scale.dtype		).eps		)
										return loc.squeeze(-1		), scale.squeeze(-1		)


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     {"total_count": 1, "logits": 1}
							_UpperCAmelCase						    =     NegativeBinomial







							@classmethod
							def 				snake_case  (				cls     :    List[Any]	,					__snake_case     :    torch.Tensor	,					__snake_case     :    torch.Tensor		):
										lowerCamelCase						:Dict						  =     cls.squareplus(__snake_case		)
										return total_count.squeeze(-1		), logits.squeeze(-1		)







							def 				snake_case  (				self     :    Tuple	,					__snake_case     :    Optional[int]		):
										lowerCamelCase  ,    lowerCamelCase						:Tuple						  =     distr_args
										if self.dim == 1:
													return self.distribution_class(total_count=__snake_case	,					logits=__snake_case		)
										else:
													return Independent(self.distribution_class(total_count=__snake_case	,					logits=__snake_case		)	,					1		)







							def 				snake_case  (				self     :    int	,					__snake_case     :    str	,					__snake_case     :    Optional[torch.Tensor] = None	,					__snake_case     :    Optional[torch.Tensor] = None		):
										lowerCamelCase  ,    lowerCamelCase						:int						  =     distr_args

										if scale is not None:
													# See scaling property of Gamma.
													logits += scale.log()

										return self._base_distribution((total_count, logits)		)




import os
from math import logaa





def  _lowerCamelCase					(   a_				: str = "base_exp.txt"):
			lowerCamelCase						:float						  =     0
			lowerCamelCase						:Optional[int]						  =     0
			for i, line in enumerate(open(os.path.join(os.path.dirname(a_)						,			a_))):
						lowerCamelCase  ,    lowerCamelCase						:Optional[int]						  =     list(map(a_						,			line.split(''',''')))
						if x * logaa(a_) > largest:
									lowerCamelCase						:List[Any]						  =     x * logaa(a_)
									lowerCamelCase						:Any						  =     i + 1
			return result


if __name__ == "__main__":
			print(solution())



