def display_and_save_latent(batch, label, data, save=True, display=True):
    'Display and save batch of 2-D latent variable using plt'
    colors = ['black', 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'pink', 'violet', 'grey']
    z = batch.cpu().detach().numpy()
    l = label.cpu().numpy()
    plt.title('Latent variables')
    plt.scatter(z[:, 0], z[:, 1], c=l, cmap=matplotlib.colors.ListedColormap(colors))
    plt.xlim((- 3), 3)
    plt.ylim((- 3), 3)
    if save:
        plt.savefig((('results/latent-variable' + data) + '.png'), transparent=True, bbox_inches='tight')
    if display:
        plt.show()
Display and save batch of 2-D latent variable using plt
def display_and_save_latent(batch, label, data, save=True, display=True):
    
    colors = ['black', 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'pink', 'violet', 'grey']
    z = batch.cpu().detach().numpy()
    l = label.cpu().numpy()
    plt.title('Latent variables')
    plt.scatter(z[:, 0], z[:, 1], c=l, cmap=matplotlib.colors.ListedColormap(colors))
    plt.xlim((- 3), 3)
    plt.ylim((- 3), 3)
    if save:
        plt.savefig((('results/latent-variable' + data) + '.png'), transparent=True, bbox_inches='tight')
    if display:
        plt.show()