"""simple docstring"""



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      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    def __init__(		self							:     List[str]	,      A_							:     Distribution	,      A_							:     Optional[int]=None	,      A_							:     Optional[Any]=None	,      A_							:     Union[str, Any]=0    )    ->       Optional[int]:
         __snake_case				=							1.0 if scale is None else scale
         __snake_case				=							0.0 if loc is None else loc

         super().__init__(A_	,      [AffineTransform(loc=self.loc	,      scale=self.scale	,      event_dim=A_    )]    )
    @property
    def  lowercase					(		self							:     Union[str, Any]    )    ->       int:
         return self.base_dist.mean * self.scale + self.loc
    @property
    def  lowercase					(		self							:     Optional[int]    )    ->       Union[str, Any]:
         return self.base_dist.variance * self.scale**2







    @property
    def  lowercase					(		self							:     Any    )    ->       str:
         return self.variance.sqrt()






class      _A	(						nn.Module					):




    """simple docstring"""




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







    def  lowercase					(		self							:     str	,      A_							:     torch.Tensor    )    ->       Tuple[torch.Tensor]:
         __snake_case				=							[proj(A_    ) for proj in self.proj]

         return self.domain_map(*A_    )






class      _A	(						nn.Module					):




    """simple docstring"""




    def __init__(		self							:     List[Any]	,      A_							:     Union[str, Any]    )    ->       int:
         super().__init__()
         __snake_case				=							function







    def  lowercase					(		self							:     Dict	,      A_							:     Dict	,      *A_							:     Optional[Any]    )    ->       Optional[Any]:
         return self.function(A_	,      *A_    )






class      _A	:




    """simple docstring"""




    UpperCamelCase_	:					type
    UpperCamelCase_	:					int
    UpperCamelCase_	:					Dict[str, int]
    def __init__(		self							:     Optional[int]	,      A_							:     int = 1    )    ->       None:
         __snake_case				=							dim
         __snake_case				=							{k: dim * self.args_dim[k] for k in self.args_dim}
    def  lowercase					(		self							:     str	,      A_							:     Optional[int]    )    ->       List[str]:
         if self.dim == 1:
              return self.distribution_class(*A_    )
         else:
              return Independent(self.distribution_class(*A_    )	,      1    )
    def  lowercase					(		self							:     Any	,      A_							:     Union[str, Any]	,      A_							:     Optional[torch.Tensor] = None	,      A_							:     Optional[torch.Tensor] = None	,      )    ->       Distribution:
         __snake_case				=							self._base_distribution(A_    )
         if loc is None and scale is None:
              return distr
         else:
              return AffineTransformed(A_	,      loc=A_	,      scale=A_	,      event_dim=self.event_dim    )
    @property
    def  lowercase					(		self							:     str    )    ->       Tuple:
         return () if self.dim == 1 else (self.dim,)
    @property
    def  lowercase					(		self							:     str    )    ->       int:
         return len(self.event_shape    )
    @property
    def  lowercase					(		self							:     Any    )    ->       float:
         return 0.0
    def  lowercase					(		self							:     List[str]	,      A_							:     int    )    ->       nn.Module:
         return ParameterProjection(
             in_features=A_	,      args_dim=self.args_dim	,      domain_map=LambdaLayer(self.domain_map    )	,      )
    def  lowercase					(		self							:     str	,      *A_							:     torch.Tensor    )    ->       Optional[int]:
         raise NotImplementedError()







    @staticmethod
    def  lowercase					(		A_							:     torch.Tensor    )    ->       torch.Tensor:
         return (x + torch.sqrt(torch.square(A_    ) + 4.0    )) / 2.0






class      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    UpperCamelCase_	:					Dict[str, int]							=					{"df": 1, "loc": 1, "scale": 1}
    UpperCamelCase_	:					type							=					StudentT
    @classmethod
    def  lowercase					(		cls							:     Optional[int]	,      A_							:     torch.Tensor	,      A_							:     torch.Tensor	,      A_							:     torch.Tensor    )    ->       Tuple:
         __snake_case				=							cls.squareplus(A_    ).clamp_min(torch.finfo(scale.dtype    ).eps    )
         __snake_case				=							2.0 + cls.squareplus(A_    )
         return df.squeeze(-1    ), loc.squeeze(-1    ), scale.squeeze(-1    )






class      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    UpperCamelCase_	:					Dict[str, int]							=					{"loc": 1, "scale": 1}
    UpperCamelCase_	:					type							=					Normal
    @classmethod
    def  lowercase					(		cls							:     Any	,      A_							:     torch.Tensor	,      A_							:     torch.Tensor    )    ->       List[str]:
         __snake_case				=							cls.squareplus(A_    ).clamp_min(torch.finfo(scale.dtype    ).eps    )
         return loc.squeeze(-1    ), scale.squeeze(-1    )






class      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    UpperCamelCase_	:					Dict[str, int]							=					{"total_count": 1, "logits": 1}
    UpperCamelCase_	:					type							=					NegativeBinomial
    @classmethod
    def  lowercase					(		cls							:     Union[str, Any]	,      A_							:     torch.Tensor	,      A_							:     torch.Tensor    )    ->       str:
         __snake_case				=							cls.squareplus(A_    )
         return total_count.squeeze(-1    ), logits.squeeze(-1    )
    def  lowercase					(		self							:     Optional[int]	,      A_							:     Union[str, Any]    )    ->       Distribution:
         __snake_case		,	__snake_case				=							distr_args
         if self.dim == 1:
              return self.distribution_class(total_count=A_	,      logits=A_    )
         else:
              return Independent(self.distribution_class(total_count=A_	,      logits=A_    )	,      1    )







    def  lowercase					(		self							:     Tuple	,      A_							:     Dict	,      A_							:     Optional[torch.Tensor] = None	,      A_							:     Optional[torch.Tensor] = None    )    ->       Distribution:
         __snake_case		,	__snake_case				=							distr_args

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

         return self._base_distribution((total_count, logits)    )
"""simple docstring"""



import qiskit





def    SCREAMING_SNAKE_CASE       (     snake_case,      snake_case):
     __snake_case				=							qiskit.Aer.get_backend('''aer_simulator''')

     # Create a Quantum Circuit acting on the q register
     __snake_case				=							qiskit.QuantumCircuit(snake_case,      snake_case)

     # Map the quantum measurement to the classical bits
     circuit.measure([0],      [0])

     # Execute the circuit on the simulator
     __snake_case				=							qiskit.execute(snake_case,      snake_case,      shots=10_00)

     # Return the histogram data of the results of the experiment.
     return job.result().get_counts(snake_case)


if __name__ == "__main__":
       print(F"""Total count for various states are: {single_qubit_measure(1, 1)}""")