I think you are handing data in the wrong shape to your first layer. Conv2D expects an input of dimension N x C x X x Y = 4 (with batch dimension N, C probably equal to 1 and then X and Y dimensions). If I am not mistaken, you use data.view to make your data 2-dimensional (instead of 4). This causes the original RuntimeError in Conv2d.
Assuming you work with the MNIST dataset (I am guessing because of the 784), your view command should probably be (with X, Y = 28):

data=Variable(data.view(-1, 1, X, Y)).to(device)

The TypeError in forward() during the execution of add_graph is probably caused by the images input. You get images, labels from your train_loader, which returns a tensor of shape N x [whatever your data shape is]. tensorboard.add_graph expects either a Tensor or a List of Tensors, according to the documentation 4.
You can find example code from the devs on how to give add_graph multiple inputs here 7.
P.S.: The Variable(something) command is deprecated. It’s not causing your error, but I think we’re not meant to use it anymore.