import osimport torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoaderfrom torchvision import transforms, datasets
from torchvision.utils import save_imagefrom tqdm import tqdmclass VAE(nn.Module): # 定义VAE模型…