About pytorch the output is not what I expect
import torch
a = torch.randn(2, 2)
a = ((a * 3) / (a - 1))
print(a)

The output is:
tensor([[  -0.7242,    2.0021],
        [-280.8320,    0.6750]])

But I think it should be:
tensor([[  6,    6],
        [  6,    6]])

Why I'm wrong?

torch.randn will preduce a random 2X2 tensor, as stated in the docs

Returns a tensor filled with random numbers from a normal distribution
with mean 0 and variance 1 (also called the standard normal
distribution).

In your case you will get the desired output if you will generate a tensor where all the values are 2.
a = torch.ones([2, 2], dtype=torch.float64) * 2. 

will give you the desired one.
