Here is an example:
import torch
import torch.nn as nn
from tensorboardX import SummaryWriter
input1 = torch.ones(1, 2)
input2 = torch.randn(1, 2)
batch_input = torch.cat((input1, input2), 0)    # Two input
class SimpleLinear(nn.Module):
def __init__(self):
    super(SimpleLinear, self).__init__()
    self.slin = nn.Linear(2, 4)

def forward(self, x):
    return self.slin(x)

with SummaryWriter(‘runs/graph2’, comment=‘SimpleLinear’) as w:

w.add_graph(SimpleLinear(), batch_input, True)