class_docstr: An implementation of
  :class:`~torch.distributions.relaxed_categorical.RelaxedOneHotCategorical`
  with a straight-through gradient estimator.
  
  This distribution has the following properties:
  
  - The samples returned by the :meth:`rsample` method are discrete/quantized.
  - The :meth:`log_prob` method returns the log probability of the
    relaxed/unquantized sample using the GumbelSoftmax distribution.
  - In the backward pass the gradient of the sample with respect to the
    parameters of the distribution uses the relaxed/unquantized sample.
  
  References:
  
  [1] The Concrete Distribution: A Continuous Relaxation of Discrete Random Variables,
      Chris J. Maddison, Andriy Mnih, Yee Whye Teh
  [2] Categorical Reparameterization with Gumbel-Softmax,
      Eric Jang, Shixiang Gu, Ben Poole
class_docstr_tok: ["An","implementation","of",":","class",":","`","~torch.distributions.relaxed_categorical.RelaxedOneHotCategorical","`","with","a","straight-through","gradient","estimator",".","This","distribution","has","the","following","properties",":","-","The","samples","returned","by","the",":","meth",":","`","rsample","`","method","are","discrete\/quantized",".","-","The",":","meth",":","`","log_prob","`","method","returns","the","log","probability","of","the","relaxed\/unquantized","sample","using","the","GumbelSoftmax","distribution",".","-","In","the","backward","pass","the","gradient","of","the","sample","with","respect","to","the","parameters","of","the","distribution","uses","the","relaxed\/unquantized","sample",".","References",":","[","1","]","The","Concrete","Distribution",":","A","Continuous","Relaxation","of","Discrete","Random","Variables",",","Chris","J.","Maddison",",","Andriy","Mnih",",","Yee","Whye","Teh","[","2","]","Categorical","Reparameterization","with","Gumbel-Softmax",",","Eric","Jang",",","Shixiang","Gu",",","Ben","Poole"]
code: def rsample(self, sample_shape=torch.Size()):
      soft_sample = super().rsample(sample_shape)
      soft_sample = clamp_probs(soft_sample)
      hard_sample = QuantizeCategorical.apply(soft_sample)
      return hard_sample
  
file_path: pyro/pyro/distributions/relaxed_straight_through.py
imports: import torch
  from torch.distributions.utils import clamp_probs
  from pyro.distributions.torch import RelaxedBernoulli, RelaxedOneHotCategorical
  from pyro.distributions.util import copy_docs_from
label_desc: Use image node_id 1 for calling the RelaxedOneHotCategoricalStraightThrough obj's underlying member method code with example usage: obj.rsample(sample_shape) and returns: hard_sample