I don’t know if there is a cleaner way  but you can do:
from torch import nn
all_layers = []
for sym in dir(nn):
    attr = getattr(nn, sym)
    if type(attr).__name__ == 'type':
        all_layers.append(attr)