for example:
x = Variable(...)

# Example 1
try:
   y = x ** 2
   z = y * 3
except:
    pass

# graph is freed here

# Example 2
try:
   y = x ** 2
   z = y * 3
   z.backward(...) # graph is freed here
except:
    pass

# Example 3
try:
   y = x ** 2
   z = y * 3
   z.backward(..., retain_variables=True)
except:
    pass
# graph is freed here