shrinath-suresh/blogs-docs-splitted huggingface dataset:
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)
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)
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.Transform(cache_size=0)
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
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:
      * domain ("Constraint") -- The constraint representing valid
        inputs to this transform.
  * **codomain** ("Constraint") -- The constraint representing
    valid outputs to this transform which are inputs to the
    inverse 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)".
  * **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)
  Computes the log det jacobian *log |dy/dx|* given input and
  output.

forward_shape(shape)
  Infers the shape of the forward computation, given the input
  shape. Defaults to preserving shape.

inverse_shape(shape)
  Infers the shapes of the inverse computation, given the output
  shape. Defaults to preserving shape.

Constraints
The following constraints are implemented:

"constraints.boolean"
"constraints.boolean"


"constraints.cat"


"constraints.corr_cholesky"


"constraints.dependent"


"constraints.greater_than(lower_bound)"


"constraints.greater_than_eq(lower_bound)"


"constraints.independent(constraint, reinterpreted_batch_ndims)"


"constraints.integer_interval(lower_bound, upper_bound)"


"constraints.interval(lower_bound, upper_bound)"


"constraints.less_than(upper_bound)"


"constraints.lower_cholesky"


"constraints.lower_triangular"


"constraints.multinomial"


"constraints.nonnegative_integer"


"constraints.one_hot"


"constraints.positive_integer"


"constraints.positive"


"constraints.positive_semidefinite"


"constraints.positive_definite"


"constraints.real_vector"


"constraints.real"


"constraints.simplex"


"constraints.symmetric"


"constraints.stack"


"constraints.square"


"constraints.symmetric"


"constraints.unit_interval"


class torch.distributions.constraints.Constraint
Abstract base class for constraints.
Abstract base class for constraints.
A constraint object represents a region over which a variable is
   valid, e.g. within which a variable can be optimized.
Variables:
      * is_discrete (bool) -- Whether constrained space is
        discrete. Defaults to False.
  * **event_dim** (*int*) -- Number of rightmost dimensions that
    together define an event. The "check()" method will remove
    this many dimensions when computing validity.

check(value)
  Returns a byte tensor of "sample_shape + batch_shape" indicating
  whether each event in value satisfies this constraint.

torch.distributions.constraints.cat
alias of "_Cat"
torch.distributions.constraints.dependent_property
alias of "_DependentProperty"
torch.distributions.constraints.greater_than
alias of "_GreaterThan"
torch.distributions.constraints.greater_than_eq
alias of "_GreaterThanEq"
torch.distributions.constraints.independent
alias of "_IndependentConstraint"
alias of "_IndependentConstraint"
torch.distributions.constraints.integer_interval
alias of "_IntegerInterval"
torch.distributions.constraints.interval
alias of "_Interval"
torch.distributions.constraints.half_open_interval
alias of "_HalfOpenInterval"
torch.distributions.constraints.less_than
alias of "_LessThan"
torch.distributions.constraints.multinomial
alias of "_Multinomial"
torch.distributions.constraints.stack
alias of "_Stack"
Constraint Registry
PyTorch provides two global "ConstraintRegistry" objects that link
"Constraint" objects to "Transform" objects. These objects both input
constraints and return transforms, but they have different guarantees
on bijectivity.

"biject_to(constraint)" looks up a bijective "Transform" from
   "constraints.real" to the given "constraint". The returned
   transform is guaranteed to have ".bijective = True" and should
   implement ".log_abs_det_jacobian()".
implement ".log_abs_det_jacobian()".

"transform_to(constraint)" looks up a not-necessarily bijective
   "Transform" from "constraints.real" to the given "constraint". The
   returned transform is not guaranteed to implement
   ".log_abs_det_jacobian()".

The "transform_to()" registry is useful for performing unconstrained
optimization on constrained parameters of probability distributions,
which are indicated by each distribution's ".arg_constraints" dict.
These transforms often overparameterize a space in order to avoid
rotation; they are thus more suitable for coordinate-wise optimization
algorithms like Adam:
loc = torch.zeros(100, requires_grad=True)
   unconstrained = torch.zeros(100, requires_grad=True)
   scale = transform_to(Normal.arg_constraints['scale'])(unconstrained)
   loss = -Normal(loc, scale).log_prob(data).sum()
The "biject_to()" registry is useful for Hamiltonian Monte Carlo,
where samples from a probability distribution with constrained
".support" are propagated in an unconstrained space, and algorithms
are typically rotation invariant.:
dist = Exponential(rate)
   unconstrained = torch.zeros(100, requires_grad=True)
   sample = biject_to(dist.support)(unconstrained)
   potential_energy = -dist.log_prob(sample).sum()
Note:
An example where "transform_to" and "biject_to" differ is
  "constraints.simplex": "transform_to(constraints.simplex)" returns a
  "SoftmaxTransform" that simply exponentiates and normalizes its
  inputs; this is a cheap and mostly coordinate-wise operation
  appropriate for algorithms like SVI. In contrast,
  "biject_to(constraints.simplex)" returns a "StickBreakingTransform"
  that bijects its input down to a one-fewer-dimensional space; this a
  more expensive less numerically stable transform but is needed for
  algorithms like HMC.
The "biject_to" and "transform_to" objects can be extended by user-
defined constraints and transforms using their ".register()" method
either as a function on singleton constraints:
transform_to.register(my_constraint, my_transform)
or as a decorator on parameterized constraints:
@transform_to.register(MyConstraintClass)
   def my_factory(constraint):
       assert isinstance(constraint, MyConstraintClass)
       return MyTransform(constraint.param1, constraint.param2)
You can create your own registry by creating a new
"ConstraintRegistry" object.
class torch.distributions.constraint_registry.ConstraintRegistry
Registry to link constraints to transforms.
register(constraint, factory=None)
  Registers a "Constraint" subclass in this registry. Usage:

     @my_registry.register(MyConstraintClass)
     def construct_transform(constraint):
         assert isinstance(constraint, MyConstraint)
         return MyTransform(constraint.arg_constraints)

  Parameters:
     * **constraint** (subclass of "Constraint") -- A subclass of
       "Constraint", or a singleton object of the desired class.
Named Tensors operator coverage
Please read Named Tensors first for an introduction to named tensors.
This document is a reference for name inference, a process that
defines how named tensors:


use names to provide additional automatic runtime correctness
   checks


propagate names from input tensors to output tensors


Below is a list of all operations that are supported with named
tensors and their associated name inference rules.
If you don't see an operation listed here, but it would help your use
case, please search if an issue has already been filed and if not,
file one.
Warning:
The named tensor API is experimental and subject to change.
Supported Operations
^^^^^^^^^^^^^^^^^^^^
+----------------------+----------------------+
| API                  | Name inference rule  |
|======================|======================|
| "Tensor.abs()",      | Keeps input names    |
| "torch.abs()"        |                      |
| "torch.abs()"        |                      |
+----------------------+----------------------+
| "Tensor.abs_()"      | Keeps input names    |
+----------------------+----------------------+
| "Tensor.acos()",     | Keeps input names    |
| "torch.acos()"       |                      |
+----------------------+----------------------+
| "Tensor.acos_()"     | Keeps input names    |
+----------------------+----------------------+
| "Tensor.add()",      | Unifies names from   |
| "torch.add()"        | inputs               |
+----------------------+----------------------+
| "Tensor.add_()"      | Unifies names from   |
|                      | inputs               |
+----------------------+----------------------+
| "Tensor.addmm()",    | Contracts away dims  |
| "torch.addmm()"      |                      |
+----------------------+----------------------+
| "Tensor.addmm_()"    | Contracts away dims  |
+----------------------+----------------------+
| "Tensor.addmv()",    | Contracts away dims  |
| "Tensor.addmv()",    | Contracts away dims  |
| "torch.addmv()"      |                      |
+----------------------+----------------------+
| "Tensor.addmv_()"    | Contracts away dims  |
+----------------------+----------------------+
| "Tensor.align_as()"  | See documentation    |
+----------------------+----------------------+
| "Tensor.align_to()"  | See documentation    |
+----------------------+----------------------+
| "Tensor.all()",      | None                 |
| "torch.all()"        |                      |
+----------------------+----------------------+
| "Tensor.any()",      | None                 |
| "torch.any()"        |                      |
+----------------------+----------------------+
| "Tensor.asin()",     | Keeps input names    |
| "torch.asin()"       |                      |
+----------------------+----------------------+
| "Tensor.asin_()"     | Keeps input names    |
+----------------------+----------------------+
| "Tensor.atan()",     | Keeps input names    |
| "Tensor.atan()",     | Keeps input names    |
| "torch.atan()"       |                      |
+----------------------+----------------------+
| "Tensor.atan2()",    | Unifies names from   |
| "torch.atan2()"      | inputs               |
+----------------------+----------------------+
| "Tensor.atan2_()"    | Unifies names from   |
|                      | inputs               |
+----------------------+----------------------+
| "Tensor.atan_()"     | Keeps input names    |
+----------------------+----------------------+
| "Tensor.bernoulli()  | Keeps input names    |
| ",                   |                      |
| "torch.bernoulli()"  |                      |
+----------------------+----------------------+
| "Tensor.bernoulli_(  | None                 |
| )"                   |                      |
+----------------------+----------------------+
| "Tensor.bfloat16()"  | Keeps input names    |
+----------------------+----------------------+
| "Tensor.bitwise_not  | Keeps input names    |
| "Tensor.bitwise_not  | Keeps input names    |
| ()", "torch.bitwise  |                      |
| not()"              |                      |
+----------------------+----------------------+
| "Tensor.bitwise_not  | None                 |
| ()"                 |                      |
+----------------------+----------------------+
| "Tensor.bmm()",      | Contracts away dims  |
| "torch.bmm()"        |                      |
+----------------------+----------------------+
| "Tensor.bool()"      | Keeps input names    |
+----------------------+----------------------+
| "Tensor.byte()"      | Keeps input names    |
+----------------------+----------------------+
| "torch.cat()"        | Unifies names from   |
|                      | inputs               |
+----------------------+----------------------+
| "Tensor.cauchy_()"   | None                 |
+----------------------+----------------------+
| "Tensor.ceil()",     | Keeps input names    |
| "torch.ceil()"       |                      |
| "torch.ceil()"       |                      |
+----------------------+----------------------+
| "Tensor.ceil_()"     | None                 |
+----------------------+----------------------+
| "Tensor.char()"      | Keeps input names    |
+----------------------+----------------------+
| "Tensor.chunk()",    | Keeps input names    |
| "torch.chunk()"      |                      |
+----------------------+----------------------+
| "Tensor.clamp()",    | Keeps input names    |
| "torch.clamp()"      |                      |
+----------------------+----------------------+
| "Tensor.clamp_()"    | None                 |
+----------------------+----------------------+
| "Tensor.copy_()"     | out function and in- |
|                      | place variants       |
+----------------------+----------------------+
| "Tensor.cos()",      | Keeps input names    |
| "torch.cos()"        |                      |
+----------------------+----------------------+
| "Tensor.cos_()"      | None                 |
| "Tensor.cos_()"      | None                 |
+----------------------+----------------------+
| "Tensor.cosh()",     | Keeps input names    |
| "torch.cosh()"       |                      |
+----------------------+----------------------+
| "Tensor.cosh_()"     | None                 |
+----------------------+----------------------+
| "Tensor.acosh()",    | Keeps input names    |
| "torch.acosh()"      |                      |
+----------------------+----------------------+
| "Tensor.acosh_()"    | None                 |
+----------------------+----------------------+
| "Tensor.cpu()"       | Keeps input names    |
+----------------------+----------------------+
| "Tensor.cuda()"      | Keeps input names    |
+----------------------+----------------------+
| "Tensor.cumprod()",  | Keeps input names    |
| "torch.cumprod()"    |                      |
+----------------------+----------------------+
| "Tensor.cumsum()",   | Keeps input names    |
| "torch.cumsum()"     |                      |
| "torch.cumsum()"     |                      |
+----------------------+----------------------+
| "Tensor.data_ptr()"  | None                 |
+----------------------+----------------------+
| "Tensor.deg2rad()",  | Keeps input names    |
| "torch.deg2rad()"    |                      |
+----------------------+----------------------+
| "Tensor.deg2rad_()"  | None                 |
+----------------------+----------------------+
| "Tensor.detach()",   | Keeps input names    |
| "torch.detach()"     |                      |
+----------------------+----------------------+
| "Tensor.detach_()"   | None                 |
+----------------------+----------------------+
| "Tensor.device",     | None                 |
| "torch.device()"     |                      |
+----------------------+----------------------+
| "Tensor.digamma()",  | Keeps input names    |
| "torch.digamma()"    |                      |
+----------------------+----------------------+
| "Tensor.digamma_()"  | None                 |
| "Tensor.digamma_()"  | None                 |
+----------------------+----------------------+
| "Tensor.dim()"       | None                 |
+----------------------+----------------------+
| "Tensor.div()",      | Unifies names from   |
| "torch.div()"        | inputs               |
+----------------------+----------------------+
| "Tensor.div_()"      | Unifies names from   |
|                      | inputs               |
+----------------------+----------------------+
| "Tensor.dot()",      | None                 |
| "torch.dot()"        |                      |
+----------------------+----------------------+
| "Tensor.double()"    | Keeps input names    |
+----------------------+----------------------+
| "Tensor.element_siz  | None                 |
| e()"                 |                      |
+----------------------+----------------------+
| "torch.empty()"      | Factory functions    |
+----------------------+----------------------+
| "torch.empty_like()" | Factory functions    |
| "torch.empty_like()" | Factory functions    |
+----------------------+----------------------+
| "Tensor.eq()",       | Unifies names from   |
| "torch.eq()"         | inputs               |
+----------------------+----------------------+
| "Tensor.erf()",      | Keeps input names    |
| "torch.erf()"        |                      |
+----------------------+----------------------+
| "Tensor.erf_()"      | None                 |
+----------------------+----------------------+
| "Tensor.erfc()",     | Keeps input names    |
| "torch.erfc()"       |                      |
+----------------------+----------------------+
| "Tensor.erfc_()"     | None                 |
+----------------------+----------------------+
| "Tensor.erfinv()",   | Keeps input names    |
| "torch.erfinv()"     |                      |
+----------------------+----------------------+
| "Tensor.erfinv_()"   | None                 |
+----------------------+----------------------+
| "Tensor.exp()",      | Keeps input names    |
| "Tensor.exp()",      | Keeps input names    |
| "torch.exp()"        |                      |
+----------------------+----------------------+
| "Tensor.exp_()"      | None                 |
+----------------------+----------------------+
| "Tensor.expand()"    | Keeps input names    |
+----------------------+----------------------+
| "Tensor.expm1()",    | Keeps input names    |
| "torch.expm1()"      |                      |
+----------------------+----------------------+
| "Tensor.expm1_()"    | None                 |
+----------------------+----------------------+
| "Tensor.exponential  | None                 |
| ()"                 |                      |
+----------------------+----------------------+
| "Tensor.fill()"     | None                 |
+----------------------+----------------------+
| "Tensor.flatten()",  | See documentation    |
| "torch.flatten()"    |                      |
+----------------------+----------------------+
| "Tensor.float()"     | Keeps input names    |
| "Tensor.float()"     | Keeps input names    |
+----------------------+----------------------+
| "Tensor.floor()",    | Keeps input names    |
| "torch.floor()"      |                      |
+----------------------+----------------------+
| "Tensor.floor_()"    | None                 |
+----------------------+----------------------+
| "Tensor.frac()",     | Keeps input names    |
| "torch.frac()"       |                      |
+----------------------+----------------------+
| "Tensor.frac_()"     | None                 |
+----------------------+----------------------+
| "Tensor.ge()",       | Unifies names from   |
| "torch.ge()"         | inputs               |
+----------------------+----------------------+
| "Tensor.get_device(  | None                 |
| )",                  |                      |
| "torch.get_device()" |                      |
+----------------------+----------------------+
| "Tensor.grad"        | None                 |
+----------------------+----------------------+
+----------------------+----------------------+
| "Tensor.gt()",       | Unifies names from   |
| "torch.gt()"         | inputs               |
+----------------------+----------------------+
| "Tensor.half()"      | Keeps input names    |
+----------------------+----------------------+
| "Tensor.has_names()" | See documentation    |
+----------------------+----------------------+
| "Tensor.index_fill(  | Keeps input names    |
| )",                  |                      |
| "torch.index_fill()" |                      |
+----------------------+----------------------+
| "Tensor.index_fill_  | None                 |
| ()"                  |                      |
+----------------------+----------------------+
| "Tensor.int()"       | Keeps input names    |
+----------------------+----------------------+
| "Tensor.is_contiguo  | None                 |
| us()"                |                      |
+----------------------+----------------------+
| "Tensor.is_cuda"     | None                 |
| "Tensor.is_cuda"     | None                 |
+----------------------+----------------------+
| "Tensor.is_floating  | None                 |
| _point()", "torch.i  |                      |
| s_floating_point()"  |                      |
+----------------------+----------------------+
| "Tensor.is_leaf"     | None                 |
+----------------------+----------------------+
| "Tensor.is_pinned()" | None                 |
+----------------------+----------------------+
| "Tensor.is_shared()" | None                 |
+----------------------+----------------------+
| "Tensor.is_signed()  | None                 |
| ",                   |                      |
| "torch.is_signed()"  |                      |
+----------------------+----------------------+
| "Tensor.is_sparse"   | None                 |
+----------------------+----------------------+
| "Tensor.is_sparse_c  | None                 |
| sr"                  |                      |
+----------------------+----------------------+