def METHOD_NAME(batch):
    batch_size = len(batch)
    gpt_max_length = max([len(x[0]) for x in batch])
    image_shape = batch[0][1][0].shape # (3, 224, 224)
    image_num = sum([len(x[1]) for x in batch])
    gpt_source_ids = np.full(shape=(batch_size, gpt_max_length-1), dtype=np.int32,
                         fill_value=self.dictionary.pad())
    gpt_target_ids = np.full(shape=(batch_size, gpt_max_length-1), dtype=np.int32,
                             fill_value=self.dictionary.pad())
    gpt_input_mask_all = np.full(shape=(batch_size, gpt_max_length-1), dtype=np.int32, fill_value=0)
    gpt_loss_mask_all = np.full(shape=(batch_size, gpt_max_length-1), dtype=np.int32, fill_value=1)
    chunk_tokens_all = np.full(shape=(batch_size, gpt_max_length-1), dtype=np.int32, fill_value=0)
    segment_tokens_all = np.full(shape=(batch_size, gpt_max_length-1), dtype=np.int32, fill_value=0)
    image_source_ids = np.full(shape=(image_num, image_shape[0], image_shape[1], image_shape[2]), dtype=np.float32,
                         fill_value=self.dictionary.pad())
    all_image_tokens = []
    for i, (full_tokens, image_tokens, text_input_mask, text_loss_mask, chunk_tokens, segment_tokens) in enumerate(batch):
        gpt_source_ids[i, :len(full_tokens)-1] = full_tokens[:-1]
        gpt_target_ids[i, :len(full_tokens)-1] = full_tokens[1:]
        gpt_input_mask_all[i, :len(full_tokens)-1] = text_input_mask[:-1]
        gpt_loss_mask_all[i, :len(full_tokens)-1] = text_loss_mask[:-1]
        chunk_tokens_all[i, :len(full_tokens)-1] = chunk_tokens[:-1]
        segment_tokens_all[i, :len(full_tokens)-1] = segment_tokens[:-1]
        # image_source_ids[i] = image_tokens
        all_image_tokens.extend(image_tokens)
    # pdb.set_trace()
    image_source_ids = np.stack(all_image_tokens)
    ret_batch = {
        'vl_mmc4':{
            'net_input': {
                'src_tokens': gpt_source_ids.astype(np.int64),
                'img_src_tokens': image_source_ids.astype(np.float32),
                'img_gpt_input_mask': gpt_input_mask_all.astype(np.bool_),
                'gpt_loss_mask': gpt_loss_mask_all.astype(np.bool_),
                'chunk_tokens': chunk_tokens_all.astype(np.int64),
                'segment_tokens': segment_tokens_all.astype(np.int64),
            },
            'target': gpt_target_ids.astype(np.int64),
            'nsentences': batch_size,
            'ntokens': sum([len(x[0]) for x in batch]),
        }
    }
    return ret_batch