Solved by ZimoNitrome in post #6 
              
              
                I updated my previous code for a circle to draw a squircle instead. 
It is close enough to a square. 
s = 256

canvas = torch.zeros([1, 1, s, s])

ss = torch.linspace(0, 1, s)
x, y = torch.meshgrid(ss, ss)

px = 0.5
py = 0.5
w = 0.5
h = 0.5
exp = 10

image = 1 - 2*(abs((x - px)/w)**exp + abs((y - py…