def __init__(self,
                 data_root,
                 image_root,
                 text_type,
                 image_type,
                 **kwargs):
        """
        Basic processing of image and text
            For image: Provide original picture and regional feature loading
            For text: Provide text processing into token
            Label info (Optional)
        :param text_type: token, bert
        :param image_type: raw, region
        """
        super(BasicDataset, self).__init__()

        self.data_root = data_root
        self.image_root = image_root
        self.text_type = text_type
        self.image_type = image_type

        self.count_thresh = kwargs.get('count_thresh', 5)
        self.token_len = kwargs.get('max_len', -1)
        self.num_boxes = kwargs.get('num_boxes', 36)
        self.add_special_token = kwargs.get('add_special_token', True)

        if kwargs.get('model_name').lower() == 'aoanet':
            self.ratio = 5
        else:
            self.ratio = 1

        # load data reader
        self.reader = CocoReader(data_root=self.data_root, image_root=self.image_root)

        # default is train dataset
        if self.ratio == 1:
            self.img_id, self.txt_id = self.reader.train_by_text()
        else:
            self.img_id, self.txt_id = self.reader.train_by_image()

        # load data preprocess
        self.tokenizer = BaseTokenizer(total_text=self.reader.total_text,
                                       data_root=self.data_root,
                                       count_thresh=self.count_thresh,
                                       max_len=self.token_len,
                                       add_special_token=self.add_special_token)

        if text_type == 'bert':
            self.bert_tokenizer = PreTokenizer(max_len=kwargs.get('max_len', 32),
                                               bert_model=kwargs.get('bert_model', 'bert-base-uncased'),
                                               add_special_token=self.add_special_token)

        # for extract global feature for image
        self.transform = T.Compose([
            T.Resize((224, 224)),
            T.ToTensor(),
            T.Normalize(mean=[0.485, 0.456, 0.406],
                        std=[0.229, 0.224, 0.225])
        ])

        self.region_processor = RegionProcessor(num_boxes=self.num_boxes)

        Basic processing of image and text
            For image: Provide original picture and regional feature loading
            For text: Provide text processing into token
            Label info (Optional)
        :param text_type: token, bert
        :param image_type: raw, region
        
torchmm/datasets/basic_dataset.py