const variable_list &input_vars, PyObject raw_output, PyObject outputs, bool is_executable)
{
  auto cdata_if_executable = is_executable ? cdata : nullptr;
 ...
// Wrap only the tensor outputs.
  // This calls csrc/autograd/custom_function.cpp
  auto wrapped_outputs = _wrap_outputs(input_vars, non_differentiable, dirty_inputs, raw_output_vars, cdata_if_executable);
...
}
```
The called _wrap_outputs is the one in charge of setting the autograd metadata in the output tensors:
```c++
std::vector> _wrap_outputs(const variable_list &input_vars,
  const std::unordered_set &non_differentiable,
  const std::unordered_set &dirty_inputs,
  const at::ArrayRef> raw_outputs,
  const std::shared_ptr &cdata) {
std::unordered_set inputs;
  …
  // Sets the grad_fn and output_nr of an output Variable.
  auto set_history = [&](Variable& var, uint32_t output_nr, bool is_input, bool is_modified,