How to plot models using torchviz or hiddenlayer

I am trying to plot models using torchviz and hiddenlayer but both gets errors.

torchviz - GitHub - waleedka/hiddenlayer: Neural network graphs and training metrics for PyTorch, Tensorflow, and Keras.
hiddenlayer - GitHub - szagoruyko/pytorchviz: A small package to create visualizations of PyTorch execution graphs

Common Code:

from transformers import AutoModel
model1 = AutoModel.from_pretrained("bert-base-uncased")

Code for torchviz :

from torchviz import make_dot, make_dot_from_trace


AttributeError: ‘BertModel’ object has no attribute ‘size’

Code for hiddenlayer:

import hiddenlayer as hl


AssertionError: Argument args must be provided for Pytorch models.

How to solve these errors or do you have any other model plot method?