Repository: truera/trulens
Issue: Explain object detection models via PyTorch backend
Root cause: Interface Contract Mismatch

Hi team, 

I'm trying to explain the output of localization models (fasterrcnn_resnet50_fpn, and others in Torchvision).
There are no issues when I wrap the pytorch model in _get_model_wrapper()_ but passing this wrapped model to _InputAttributions()_ or _IntegratedGradients()_ throws, what seems a trivial PyTorch error:

Would you know, where in trulens/pytorch.py are we creating views and if that's something that can be quickly fixed?

```
RuntimeError                              Traceback (most recent call last)
<ipython-input-43-9b10bbb33c8d> in <module>()
      1 infl = InputAttribution(model)
----> 2 attrs_input = infl.attributions(x_pp)

7 frames
/usr/local/lib/python3.7/dist-packages/trulens/nn/attribution.py in attributions(self, *model_args, **model_kwargs)
    269             to_cut=self.slice.to_cut,
    270             intervention=D,
--> 271             doi_cut=doi_cut)
    272         # Take the mean across the samples in the DoI.
    273         if isinstance(qoi_grads, DATA_CONTAINER_TYPE):

/usr/local/lib/python3.7/dist-packages/trulens/nn/models/pytorch.py in qoi_bprop(self, qoi, model_args, model_kwargs, doi_cut, to_cut, attribution_cut, intervention)
    455             attribution_cut=attribution_cut,
    456             intervention=intervention,
--> 457             return_tensor=False)
    458 
    459         y = to_cut.access_layer(y)

/usr/local/lib/python3.7/dist-packages/trulens/nn/models/pytorch.py in fprop(self, model_args, model_kwargs, doi_cut, to_cut, attribution_cut, intervention, return_tensor, input_timestep)
    370         ]
    371         # Run the network.
--> 372         output = self.model(*model_args, **model_kwargs)
    373         if isinstance(output, tuple):
    374             output = output[0]

/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
   1049         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1050                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1051             return forward_call(*input, **kwargs)
   1052         # Do not call functions when jit is used
   1053         full_backward_hooks, non_full_backward_hooks = [], []

/usr/local/lib/python3.7/dist-packages/torchvision/models/detection/generalized_rcnn.py in forward(self, images, targets)
     75             original_image_sizes.append((val[0], val[1]))
     76 
---> 77         images, targets = self.transform(images, targets)
     78 
     79         # Check for degenerate boxes

/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
   1049         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1050                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1051             return forward_call(*input, **kwargs)
   1052         # Do not call functions when jit is used
   1053         full_backward_hooks, non_full_backward_hooks = [], []

/usr/local/lib/python3.7/dist-packages/torchvision/models/detection/transform.py in forward(self, images, targets)
    118 
    119         image_sizes = [img.shape[-2:] for img in images]
--> 120         images = self.batch_images(images, size_divisible=self.size_divisible)
    121         image_sizes_list: List[Tuple[int, int]] = []
    122         for image_size in image_sizes:

/usr/local/lib/python3.7/dist-packages/torchvision/models/detection/transform.py in batch_images(self, images, size_divisible)
    222         batched_imgs = images[0].new_full(batch_shape, 0)
    223         for img, pad_img in zip(images, batched_imgs):
--> 224             pad_img[: img.shape[0], : img.shape[1], : img.shape[2]].copy_(img)
    225 
    226         return batched_imgs

RuntimeError: A view was created in no_grad mode and is being modified inplace with grad mode enabled. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.
```