I would like to visualize the number of image data for each class of the cifar10 dataset on a graph.I have tried implementing this on pytorch but I couldn’t get any satisfying results. Can anyone please help me to plot the CIFAR10 Dataset classes frequency .
Here is an exemple of an implementation i have tried but i keep getting an error when comparing labels with the classes indexes
def classes_freq():
    for images, labels in trainloader_classes:
          #print(labels.shape)
      
          images = images.to(device)
          labels = labels.to(device)
          count = [0]*10
          for k in range(len(trainloader_classes)):
            for i,e in enumerate(classes):
             if (labels[k].item() == i):
                count[i]+=1
    return count

classes_freq()


import matplotlib.pyplot as plt

def plot(y_units):

  x_units = ['plane', 'car', 'bird', 'cat',
           'deer', 'dog', 'frog', 'horse', 'ship', 'truck']

  plt.bar(x_units, y_units,width=0.8, color=['red','blue'])

  plt.xlabel('x - axis')
  plt.ylabel('y - axis')
  plt.title('classes frequency')

  plt.show()

#plot([10,20,23,50,60,70,80,90,10,45])

Error:

IndexError: index 1 is out of bounds for dimension 0 with size 1