# How to visualize Backward (and perhaps DoubleBackward) pass of variable?

**URL:** <https://discuss.pytorch.org/t/how-to-visualize-backward-and-perhaps-doublebackward-pass-of-variable/108456>\
**Category:** Uncategorized\
**Created:** [January 10, 2021, 9:09pm UTC](https://discuss.pytorch.org/t/how-to-visualize-backward-and-perhaps-doublebackward-pass-of-variable/108456 "2021-01-10T21:09:46Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![AlphaBetaGamma96](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/3da27b/32.png) [@AlphaBetaGamma96](https://discuss.pytorch.org/u/AlphaBetaGamma96)\
**Post date:** [January 11, 2021, 5:09pm UTC](https://discuss.pytorch.org/t/how-to-visualize-backward-and-perhaps-doublebackward-pass-of-variable/108456/5 "2021-01-11T17:09:11Z")

</div>

Sorry I should’ve made this a bit clearer, the output of the custom\_det function returns `[B,]` for an input of `[B, N, N]`. What I mentioned above was the size of the input matrix, the size of the 1st order gradient w.r.t the input matrix (from the first backward method), and the size of the 2nd order gradient w.r.t the input matrix (from the second backward method).

Also, I think I’ve just realised that the Tensor of `[25, 4, 4]` could be the `grad_output` which is returned in the Double Backward method?

Also, also, how exactly do I set `TORCH_SHOW_CPP_STACKTRACES=1` ? I saw from [this](https://discuss.pytorch.org/t/debug-autograd/88598/4) question you state it needs to be enabled before importing torch. Would this be enable via something like this?

```auto
import os 
os.environ['TORCH_SHOW_CPP_STACKTRACES'] = "1"
import torch

```

Thank you

Edit: I’ve added these lines to the code of my code, and nothing has changed with the `torchviz` diagram. (So I’ve probably implemented it wrong?)

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-visualize-backward-and-perhaps-doublebackward-pass-of-variable/108456)._
