import torch import torch.nn as nn from torch.utils.tensorboard import SummaryWriter # Define a simple PyTorch model class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.fc1 = nn.Linear(784, 256) self.fc2 = nn.Linear(256, 10) def forward(self, x): x = torch.flatten(x, 1) x = self.fc1(x) x = nn.functional.relu(x) x = self.fc2(x) return x net = Net() # Create a SummaryWriter object writer = SummaryWriter() # Add the model graph to the log file inputs = torch.randn(1, 1, 28, 28) writer.add_graph(net, inputs) # Close the SummaryWriter object writer.close()In this example, we define a simple neural network model called "Net" and then create an instance of it. We then create a SummaryWriter object and use the add_graph method to add the model graph to the TensorBoard log file. Finally, we close the SummaryWriter object. The above code example makes use of the PyTorch package library.