Custom loss function in PyTorch : <p>I have three simple questions.</p>

<ol>
<li>What will happen if my custom loss function is not differentiable? Will pytorch through error or do something else?</li>
<li>If I declare a loss variable in my custom function which will represent the final loss of the model, should I put <code>requires_grad = True</code> for that variable? or it doesn't matter? If it doesn't matter, then why?</li>
<li>I have seen people sometimes write a separate layer and compute the loss in the <code>forward</code> function. Which approach is preferable, writing a function or a layer? Why?</li>
</ol>

<p>I need a clear and nice explanation to these questions to resolve my confusions. Please help.</p>
