neulab/docprompting-conala huggingface dataset:
class torch.distributions.multivariate_normal.MultivariateNormal(loc, covariance_matrix=None, precision_matrix=None, scale_tril=None, validate_args=None) [source]
 
Bases: torch.distributions.distribution.Distribution Creates a multivariate normal (also called Gaussian) distribution parameterized by a mean vector and a covariance matrix. The multivariate normal distribution can be parameterized either in terms of a positive definite covariance matrix Σ\mathbf{\Sigma}  or a positive definite precision matrix Σ−1\mathbf{\Sigma}^{-1}  or a lower-triangular matrix L\mathbf{L}  with positive-valued diagonal entries, such that Σ=LL⊤\mathbf{\Sigma} = \mathbf{L}\mathbf{L}^\top . This triangular matrix can be obtained via e.g. Cholesky decomposition of the covariance. Example >>> m = MultivariateNormal(torch.zeros(2), torch.eye(2))
>>> m.sample()  # normally distributed with mean=`[0,0]` and covariance_matrix=`I`
tensor([-0.2102, -0.5429])
  Parameters 
 
loc (Tensor) – mean of the distribution 
covariance_matrix (Tensor) – positive-definite covariance matrix 
precision_matrix (Tensor) – positive-definite precision matrix 
scale_tril (Tensor) – lower-triangular factor of covariance, with positive-valued diagonal     Note Only one of covariance_matrix or precision_matrix or scale_tril can be specified. Using scale_tril will be more efficient: all computations internally are based on scale_tril. If covariance_matrix or precision_matrix is passed instead, it is only used to compute the corresponding lower triangular matrices using a Cholesky decomposition.   
arg_constraints = {'covariance_matrix': PositiveDefinite(), 'loc': IndependentConstraint(Real(), 1), 'precision_matrix': PositiveDefinite(), 'scale_tril': LowerCholesky()} 
  
covariance_matrix [source]

  
entropy() [source]

  
expand(batch_shape, _instance=None) [source]

  
has_rsample = True 
  
log_prob(value) [source]

  
property mean 
  
precision_matrix [source]

  
rsample(sample_shape=torch.Size([])) [source]

  
scale_tril [source]

  
support = IndependentConstraint(Real(), 1) 
  
property variance
arg_constraints = {'covariance_matrix': PositiveDefinite(), 'loc': IndependentConstraint(Real(), 1), 'precision_matrix': PositiveDefinite(), 'scale_tril': LowerCholesky()}
class torch.distributions.negative_binomial.NegativeBinomial(total_count, probs=None, logits=None, validate_args=None) [source]
 
Bases: torch.distributions.distribution.Distribution Creates a Negative Binomial distribution, i.e. distribution of the number of successful independent and identical Bernoulli trials before total_count failures are achieved. The probability of failure of each Bernoulli trial is probs.  Parameters 
 
total_count (float or Tensor) – non-negative number of negative Bernoulli trials to stop, although the distribution is still valid for real valued count 
probs (Tensor) – Event probabilities of failure in the half open interval [0, 1) 
logits (Tensor) – Event log-odds for probabilities of failure     
arg_constraints = {'logits': Real(), 'probs': HalfOpenInterval(lower_bound=0.0, upper_bound=1.0), 'total_count': GreaterThanEq(lower_bound=0)} 
  
expand(batch_shape, _instance=None) [source]

  
log_prob(value) [source]

  
logits [source]

  
property mean 
  
property param_shape 
  
probs [source]

  
sample(sample_shape=torch.Size([])) [source]

  
support = IntegerGreaterThan(lower_bound=0) 
  
property variance
arg_constraints = {'logits': Real(), 'probs': HalfOpenInterval(lower_bound=0.0, upper_bound=1.0), 'total_count': GreaterThanEq(lower_bound=0)}
class torch.distributions.normal.Normal(loc, scale, validate_args=None) [source]
 
Bases: torch.distributions.exp_family.ExponentialFamily Creates a normal (also called Gaussian) distribution parameterized by loc and scale. Example: >>> m = Normal(torch.tensor([0.0]), torch.tensor([1.0]))
>>> m.sample()  # normally distributed with loc=0 and scale=1
tensor([ 0.1046])
  Parameters 
 
loc (float or Tensor) – mean of the distribution (often referred to as mu) 
scale (float or Tensor) – standard deviation of the distribution (often referred to as sigma)     
arg_constraints = {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)} 
  
cdf(value) [source]

  
entropy() [source]

  
expand(batch_shape, _instance=None) [source]

  
has_rsample = True 
  
icdf(value) [source]

  
log_prob(value) [source]

  
property mean 
  
rsample(sample_shape=torch.Size([])) [source]

  
sample(sample_shape=torch.Size([])) [source]

  
property stddev 
  
support = Real() 
  
property variance
class torch.distributions.one_hot_categorical.OneHotCategorical(probs=None, logits=None, validate_args=None) [source]
 
Bases: torch.distributions.distribution.Distribution Creates a one-hot categorical distribution parameterized by probs or logits. Samples are one-hot coded vectors of size probs.size(-1).  Note The probs argument must be non-negative, finite and have a non-zero sum, and it will be normalized to sum to 1 along the last dimension. attr:probs will return this normalized value. The logits argument will be interpreted as unnormalized log probabilities and can therefore be any real number. It will likewise be normalized so that the resulting probabilities sum to 1 along the last dimension. attr:logits will return this normalized value.  See also: torch.distributions.Categorical() for specifications of probs and logits. Example: >>> m = OneHotCategorical(torch.tensor([ 0.25, 0.25, 0.25, 0.25 ]))
>>> m.sample()  # equal probability of 0, 1, 2, 3
tensor([ 0.,  0.,  0.,  1.])
  Parameters 
 
probs (Tensor) – event probabilities 
logits (Tensor) – event log probabilities (unnormalized)     
arg_constraints = {'logits': IndependentConstraint(Real(), 1), 'probs': Simplex()} 
  
entropy() [source]

  
enumerate_support(expand=True) [source]

  
expand(batch_shape, _instance=None) [source]

  
has_enumerate_support = True 
  
log_prob(value) [source]

  
property logits 
  
property mean 
  
property param_shape 
  
property probs 
  
sample(sample_shape=torch.Size([])) [source]

  
support = OneHot() 
  
property variance
class torch.distributions.pareto.Pareto(scale, alpha, validate_args=None) [source]
 
Bases: torch.distributions.transformed_distribution.TransformedDistribution Samples from a Pareto Type 1 distribution. Example: >>> m = Pareto(torch.tensor([1.0]), torch.tensor([1.0]))
>>> m.sample()  # sample from a Pareto distribution with scale=1 and alpha=1
tensor([ 1.5623])
  Parameters 
 
scale (float or Tensor) – Scale parameter of the distribution 
alpha (float or Tensor) – Shape parameter of the distribution     
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {'alpha': GreaterThan(lower_bound=0.0), 'scale': GreaterThan(lower_bound=0.0)} 
  
entropy() [source]

  
expand(batch_shape, _instance=None) [source]

  
property mean 
  
property support 
  
property variance
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {'alpha': GreaterThan(lower_bound=0.0), 'scale': GreaterThan(lower_bound=0.0)}
class torch.distributions.poisson.Poisson(rate, validate_args=None) [source]
 
Bases: torch.distributions.exp_family.ExponentialFamily Creates a Poisson distribution parameterized by rate, the rate parameter. Samples are nonnegative integers, with a pmf given by  rateke−ratek!\mathrm{rate}^k \frac{e^{-\mathrm{rate}}}{k!}  
Example: >>> m = Poisson(torch.tensor([4]))
>>> m.sample()
tensor([ 3.])
  Parameters 
rate (Number, Tensor) – the rate parameter    
arg_constraints = {'rate': GreaterThan(lower_bound=0.0)} 
  
expand(batch_shape, _instance=None) [source]

  
log_prob(value) [source]

  
property mean 
  
sample(sample_shape=torch.Size([])) [source]

  
support = IntegerGreaterThan(lower_bound=0) 
  
property variance
class torch.distributions.relaxed_bernoulli.LogitRelaxedBernoulli(temperature, probs=None, logits=None, validate_args=None) [source]
 
Bases: torch.distributions.distribution.Distribution Creates a LogitRelaxedBernoulli distribution parameterized by probs or logits (but not both), which is the logit of a RelaxedBernoulli distribution. Samples are logits of values in (0, 1). See [1] for more details.  Parameters 
 
temperature (Tensor) – relaxation temperature 
probs (Number, Tensor) – the probability of sampling 1
 
logits (Number, Tensor) – the log-odds of sampling 1
    [1] The Concrete Distribution: A Continuous Relaxation of Discrete Random Variables (Maddison et al, 2017) [2] Categorical Reparametrization with Gumbel-Softmax (Jang et al, 2017)  
arg_constraints = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)} 
  
expand(batch_shape, _instance=None) [source]

  
log_prob(value) [source]

  
logits [source]

  
property param_shape 
  
probs [source]

  
rsample(sample_shape=torch.Size([])) [source]

  
support = Real()
class torch.distributions.relaxed_bernoulli.RelaxedBernoulli(temperature, probs=None, logits=None, validate_args=None) [source]
 
Bases: torch.distributions.transformed_distribution.TransformedDistribution Creates a RelaxedBernoulli distribution, parametrized by temperature, and either probs or logits (but not both). This is a relaxed version of the Bernoulli distribution, so the values are in (0, 1), and has reparametrizable samples. Example: >>> m = RelaxedBernoulli(torch.tensor([2.2]),
                         torch.tensor([0.1, 0.2, 0.3, 0.99]))
>>> m.sample()
tensor([ 0.2951,  0.3442,  0.8918,  0.9021])
  Parameters 
 
temperature (Tensor) – relaxation temperature 
probs (Number, Tensor) – the probability of sampling 1
 
logits (Number, Tensor) – the log-odds of sampling 1
     
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)} 
  
expand(batch_shape, _instance=None) [source]

  
has_rsample = True 
  
property logits 
  
property probs 
  
support = Interval(lower_bound=0.0, upper_bound=1.0) 
  
property temperature
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {'logits': Real(), 'probs': Interval(lower_bound=0.0, upper_bound=1.0)}
class torch.distributions.relaxed_categorical.RelaxedOneHotCategorical(temperature, probs=None, logits=None, validate_args=None) [source]
 
Bases: torch.distributions.transformed_distribution.TransformedDistribution Creates a RelaxedOneHotCategorical distribution parametrized by temperature, and either probs or logits. This is a relaxed version of the OneHotCategorical distribution, so its samples are on simplex, and are reparametrizable. Example: >>> m = RelaxedOneHotCategorical(torch.tensor([2.2]),
                                 torch.tensor([0.1, 0.2, 0.3, 0.4]))
>>> m.sample()
tensor([ 0.1294,  0.2324,  0.3859,  0.2523])
  Parameters 
 
temperature (Tensor) – relaxation temperature 
probs (Tensor) – event probabilities 
logits (Tensor) – unnormalized log probability for each event     
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {'logits': IndependentConstraint(Real(), 1), 'probs': Simplex()} 
  
expand(batch_shape, _instance=None) [source]

  
has_rsample = True 
  
property logits 
  
property probs 
  
support = Simplex() 
  
property temperature
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {'logits': IndependentConstraint(Real(), 1), 'probs': Simplex()}
class torch.distributions.studentT.StudentT(df, loc=0.0, scale=1.0, validate_args=None) [source]
 
Bases: torch.distributions.distribution.Distribution Creates a Student’s t-distribution parameterized by degree of freedom df, mean loc and scale scale. Example: >>> m = StudentT(torch.tensor([2.0]))
>>> m.sample()  # Student's t-distributed with degrees of freedom=2
tensor([ 0.1046])
  Parameters 
 
df (float or Tensor) – degrees of freedom 
loc (float or Tensor) – mean of the distribution 
scale (float or Tensor) – scale of the distribution     
arg_constraints = {'df': GreaterThan(lower_bound=0.0), 'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)} 
  
entropy() [source]

  
expand(batch_shape, _instance=None) [source]

  
has_rsample = True 
  
log_prob(value) [source]

  
property mean 
  
rsample(sample_shape=torch.Size([])) [source]

  
support = Real() 
  
property variance
arg_constraints = {'df': GreaterThan(lower_bound=0.0), 'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}
class torch.distributions.transformed_distribution.TransformedDistribution(base_distribution, transforms, validate_args=None) [source]
 
Bases: torch.distributions.distribution.Distribution Extension of the Distribution class, which applies a sequence of Transforms to a base distribution. Let f be the composition of transforms applied: X ~ BaseDistribution
Y = f(X) ~ TransformedDistribution(BaseDistribution, f)
log p(Y) = log p(X) + log |det (dX/dY)|
 Note that the .event_shape of a TransformedDistribution is the maximum shape of its base distribution and its transforms, since transforms can introduce correlations among events. An example for the usage of TransformedDistribution would be: # Building a Logistic Distribution
# X ~ Uniform(0, 1)
# f = a + b * logit(X)
# Y ~ f(X) ~ Logistic(a, b)
base_distribution = Uniform(0, 1)
transforms = [SigmoidTransform().inv, AffineTransform(loc=a, scale=b)]
logistic = TransformedDistribution(base_distribution, transforms)
 For more examples, please look at the implementations of Gumbel, HalfCauchy, HalfNormal, LogNormal, Pareto, Weibull, RelaxedBernoulli and RelaxedOneHotCategorical  
arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {} 
  
cdf(value) [source]
 
Computes the cumulative distribution function by inverting the transform(s) and computing the score of the base distribution. 
  
expand(batch_shape, _instance=None) [source]

  
property has_rsample 
  
icdf(value) [source]
 
Computes the inverse cumulative distribution function using transform(s) and computing the score of the base distribution. 
  
log_prob(value) [source]
 
Scores the sample by inverting the transform(s) and computing the score using the score of the base distribution and the log abs det jacobian. 
  
rsample(sample_shape=torch.Size([])) [source]
 
Generates a sample_shape shaped reparameterized sample or sample_shape shaped batch of reparameterized samples if the distribution parameters are batched. Samples first from base distribution and applies transform() for every transform in the list. 
  
sample(sample_shape=torch.Size([])) [source]
 
Generates a sample_shape shaped sample or sample_shape shaped batch of samples if the distribution parameters are batched. Samples first from base distribution and applies transform() for every transform in the list. 
  
property support
cdf(value) [source]
 
Computes the cumulative distribution function by inverting the transform(s) and computing the score of the base distribution.
icdf(value) [source]
 
Computes the inverse cumulative distribution function using transform(s) and computing the score of the base distribution.
log_prob(value) [source]
 
Scores the sample by inverting the transform(s) and computing the score using the score of the base distribution and the log abs det jacobian.
rsample(sample_shape=torch.Size([])) [source]
 
Generates a sample_shape shaped reparameterized sample or sample_shape shaped batch of reparameterized samples if the distribution parameters are batched. Samples first from base distribution and applies transform() for every transform in the list.
sample(sample_shape=torch.Size([])) [source]
 
Generates a sample_shape shaped sample or sample_shape shaped batch of samples if the distribution parameters are batched. Samples first from base distribution and applies transform() for every transform in the list.
class torch.distributions.transforms.AbsTransform(cache_size=0) [source]
 
Transform via the mapping y=∣x∣y = |x| .
class torch.distributions.transforms.AffineTransform(loc, scale, event_dim=0, cache_size=0) [source]
 
Transform via the pointwise affine mapping y=loc+scale×xy = \text{loc} + \text{scale} \times x .  Parameters 
 
loc (Tensor or float) – Location parameter. 
scale (Tensor or float) – Scale parameter. 
event_dim (int) – Optional size of event_shape. This should be zero for univariate random variables, 1 for distributions over vectors, 2 for distributions over matrices, etc.
class torch.distributions.transforms.ComposeTransform(parts, cache_size=0) [source]
 
Composes multiple transforms in a chain. The transforms being composed are responsible for caching.  Parameters 
 
parts (list of Transform) – A list of transforms to compose. 
cache_size (int) – Size of cache. If zero, no caching is done. If one, the latest single value is cached. Only 0 and 1 are supported.
class torch.distributions.transforms.CorrCholeskyTransform(cache_size=0) [source]
 
Transforms an uncontrained real vector xx  with length D∗(D−1)/2D*(D-1)/2  into the Cholesky factor of a D-dimension correlation matrix. This Cholesky factor is a lower triangular matrix with positive diagonals and unit Euclidean norm for each row. The transform is processed as follows:  First we convert x into a lower triangular matrix in row order. For each row XiX_i  of the lower triangular part, we apply a signed version of class StickBreakingTransform to transform XiX_i  into a unit Euclidean length vector using the following steps: - Scales into the interval (−1,1)(-1, 1)  domain: ri=tanh⁡(Xi)r_i = \tanh(X_i) . - Transforms into an unsigned domain: zi=ri2z_i = r_i^2 . - Applies si=StickBreakingTransform(zi)s_i = StickBreakingTransform(z_i) . - Transforms back into signed domain: yi=sign(ri)∗siy_i = sign(r_i) * \sqrt{s_i} .
class torch.distributions.transforms.ExpTransform(cache_size=0) [source]
 
Transform via the mapping y=exp⁡(x)y = \exp(x) .
class torch.distributions.transforms.IndependentTransform(base_transform, reinterpreted_batch_ndims, cache_size=0) [source]
 
Wrapper around another transform to treat reinterpreted_batch_ndims-many extra of the right most dimensions as dependent. This has no effect on the forward or backward transforms, but does sum out reinterpreted_batch_ndims-many of the rightmost dimensions in log_abs_det_jacobian().  Parameters 
 
base_transform (Transform) – A base transform. 
reinterpreted_batch_ndims (int) – The number of extra rightmost dimensions to treat as dependent.
class torch.distributions.transforms.LowerCholeskyTransform(cache_size=0) [source]
 
Transform from unconstrained matrices to lower-triangular matrices with nonnegative diagonal entries. This is useful for parameterizing positive definite matrices in terms of their Cholesky factorization.
class torch.distributions.transforms.PowerTransform(exponent, cache_size=0) [source]
 
Transform via the mapping y=xexponenty = x^{\text{exponent}} .
class torch.distributions.transforms.ReshapeTransform(in_shape, out_shape, cache_size=0) [source]
 
Unit Jacobian transform to reshape the rightmost part of a tensor. Note that in_shape and out_shape must have the same number of elements, just as for torch.Tensor.reshape().  Parameters 
 
in_shape (torch.Size) – The input event shape. 
out_shape (torch.Size) – The output event shape.
class torch.distributions.transforms.SigmoidTransform(cache_size=0) [source]
 
Transform via the mapping y=11+exp⁡(−x)y = \frac{1}{1 + \exp(-x)}  and x=logit(y)x = \text{logit}(y) .
class torch.distributions.transforms.SoftmaxTransform(cache_size=0) [source]
 
Transform from unconstrained space to the simplex via y=exp⁡(x)y = \exp(x)  then normalizing. This is not bijective and cannot be used for HMC. However this acts mostly coordinate-wise (except for the final normalization), and thus is appropriate for coordinate-wise optimization algorithms.
class torch.distributions.transforms.StackTransform(tseq, dim=0, cache_size=0) [source]
 
Transform functor that applies a sequence of transforms tseq component-wise to each submatrix at dim in a way compatible with torch.stack().  Example::

x = torch.stack([torch.range(1, 10), torch.range(1, 10)], dim=1) t = StackTransform([ExpTransform(), identity_transform], dim=1) y = t(x)
class torch.distributions.transforms.StickBreakingTransform(cache_size=0) [source]
 
Transform from unconstrained space to the simplex of one additional dimension via a stick-breaking process. This transform arises as an iterated sigmoid transform in a stick-breaking construction of the Dirichlet distribution: the first logit is transformed via sigmoid to the first probability and the probability of everything else, and then the process recurses. This is bijective and appropriate for use in HMC; however it mixes coordinates together and is less appropriate for optimization.
class torch.distributions.transforms.TanhTransform(cache_size=0) [source]
 
Transform via the mapping y=tanh⁡(x)y = \tanh(x) . It is equivalent to `
ComposeTransform([AffineTransform(0., 2.), SigmoidTransform(), AffineTransform(-1., 2.)])
` However this might not be numerically stable, thus it is recommended to use TanhTransform instead. Note that one should use cache_size=1 when it comes to NaN/Inf values.
class torch.distributions.transforms.Transform(cache_size=0) [source]
 
Abstract class for invertable transformations with computable log det jacobians. They are primarily used in torch.distributions.TransformedDistribution. Caching is useful for transforms whose inverses are either expensive or numerically unstable. Note that care must be taken with memoized values since the autograd graph may be reversed. For example while the following works with or without caching: y = t(x)
t.log_abs_det_jacobian(x, y).backward()  # x will receive gradients.
 However the following will error when caching due to dependency reversal: y = t(x)
z = t.inv(y)
grad(z.sum(), [y])  # error because z is x
 Derived classes should implement one or both of _call() or _inverse(). Derived classes that set bijective=True should also implement log_abs_det_jacobian().  Parameters 
cache_size (int) – Size of cache. If zero, no caching is done. If one, the latest single value is cached. Only 0 and 1 are supported.  Variables 
 
~Transform.domain (Constraint) – The constraint representing valid inputs to this transform. 
~Transform.codomain (Constraint) – The constraint representing valid outputs to this transform which are inputs to the inverse transform. 
~Transform.bijective (bool) – Whether this transform is bijective. A transform t is bijective iff t.inv(t(x)) == x and t(t.inv(y)) == y for every x in the domain and y in the codomain. Transforms that are not bijective should at least maintain the weaker pseudoinverse properties t(t.inv(t(x)) == t(x) and t.inv(t(t.inv(y))) == t.inv(y). 
~Transform.sign (int or Tensor) – For bijective univariate transforms, this should be +1 or -1 depending on whether transform is monotone increasing or decreasing.     
property inv  
Returns the inverse Transform of this transform. This should satisfy t.inv.inv is t. 
  
property sign  
Returns the sign of the determinant of the Jacobian, if applicable. In general this only makes sense for bijective transforms. 
  
log_abs_det_jacobian(x, y) [source]
 
Computes the log det jacobian log |dy/dx| given input and output. 
  
forward_shape(shape) [source]
 
Infers the shape of the forward computation, given the input shape. Defaults to preserving shape. 
  
inverse_shape(shape) [source]
 
Infers the shapes of the inverse computation, given the output shape. Defaults to preserving shape.
forward_shape(shape) [source]
 
Infers the shape of the forward computation, given the input shape. Defaults to preserving shape.
property inv  
Returns the inverse Transform of this transform. This should satisfy t.inv.inv is t.
inverse_shape(shape) [source]
 
Infers the shapes of the inverse computation, given the output shape. Defaults to preserving shape.
log_abs_det_jacobian(x, y) [source]
 
Computes the log det jacobian log |dy/dx| given input and output.
property sign  
Returns the sign of the determinant of the Jacobian, if applicable. In general this only makes sense for bijective transforms.