torch.bernoulli
torch.bernoulli(input, *, generator=None, out=None) -> Tensor
Draws binary random numbers (0 or 1) from a Bernoulli distribution.
The "input" tensor should be a tensor containing probabilities to
   be used for drawing the binary random number. Hence, all values in
   "input" have to be in the range: 0 \leq \text{input}_i \leq 1.
The \text{i}^{th} element of the output tensor will draw a value 1
   according to the \text{i}^{th} probability value given in "input".
  \text{out}_{i} \sim \mathrm{Bernoulli}(p = \text{input}_{i})

The returned "out" tensor only has values 0 or 1 and is of the same
   shape as "input".
"out" can have integral "dtype", but "input" must have floating
   point "dtype".
Parameters:
      input (Tensor) -- the input tensor of probability values
      for the Bernoulli distribution
Keyword Arguments:
      * generator ("torch.Generator", optional) -- a pseudorandom
        number generator for sampling