from collections import defaultdict import json import numpy as np import os import pandas as pd import dill as pickle pickle._dill._reverse_typemap['ClassType'] = type import random import string import sys import torch from torch import nn import torch.nn.functional as nnf from torch.utils.data import Dataset, DataLoader from tqdm import tqdm from transformers import GPT2Tokenizer, GPT2LMHeadModel, AdamW, get_linear_schedule_with_warmup from typing import Tuple, List, Union, Optional from clipcap import *