def build_dataset_for_caption_inference_with_embed(self, src_tokens, src_lengths, img_src_tokens, img_attention_masks, img_gpt_input_mask, segment_tokens, image_paths, widths, heights, **kwargs):
        """
        Generate batches for inference. We prepend an eos token to src_tokens
        (or bos if `--add-bos-token` is set) and we append a <pad> to target.
        This is convenient both for generation with a prefix and LM scoring.
        """
        dataset = StripTokenDataset(
            TokenBlockDataset(
                src_tokens,
                src_lengths,
                block_size=None,  # ignored for "eos" break mode
                pad=self.source_dictionary.pad(),
                eos=self.source_dictionary.eos(),
                break_mode="eos",
            ),
            # remove eos from (end of) target sequence
            self.source_dictionary.eos(),
        )
        img_gpt_input_mask = StripTokenDataset(
            TokenBlockDataset(
                img_gpt_input_mask,
                src_lengths,
                block_size=None,  # ignored for "eos" break mode
                pad=self.source_dictionary.pad(),
                eos=self.source_dictionary.eos(),
                break_mode="eos",
            ),
            # remove eos from (end of) target sequence
            self.source_dictionary.eos(),
        )
        img_attention_masks = StripTokenDataset(
            TokenBlockDataset(
                img_attention_masks,
                [MAX_PATHES],
                block_size=None,  # ignored for "eos" break mode
                pad=0,
                eos=self.source_dictionary.eos(),
                break_mode="eos",
            ),
            # remove eos from (end of) target sequence
            self.source_dictionary.eos(),
        )
        # chunk_tokens = StripTokenDataset(
        #     TokenBlockDataset(
        #         chunk_tokens,
        #         src_lengths,
        #         block_size=None,  # ignored for "eos" break mode
        #         pad=self.source_dictionary.pad(),
        #         eos=self.source_dictionary.eos(),
        #         break_mode="eos",
        #     ),
        #     # remove eos from (end of) target sequence
        #     self.source_dictionary.eos(),
        # )
        segment_tokens = StripTokenDataset(
            TokenBlockDataset(
                segment_tokens,
                src_lengths,
                block_size=None,  # ignored for "eos" break mode
                pad=self.source_dictionary.pad(),
                eos=self.source_dictionary.eos(),
                break_mode="eos",
            ),
            # remove eos from (end of) target sequence
            self.source_dictionary.eos(),
        )
        src_dataset = dataset
        # PrependTokenDataset(
        #     dataset,
        #     token=(
        #         self.source_dictionary.bos()
        #         if getattr(self.args, "add_bos_token", False)
        #         else self.source_dictionary.eos()
        #     ),
        # )
        tgt_dataset = AppendTokenDataset(dataset, token=self.source_dictionary.pad())
        return NestedDictionaryDataset(
            {
                "id": IdDataset(),
                "net_input": {
                    "src_tokens": PadDataset(
                        src_dataset,
                        pad_idx=self.source_dictionary.pad(),
                        left_pad=False,
                    ),
                    'img_src_tokens': RawImageDataset(
                        img_src_tokens,
                    ),
                    'img_gpt_input_mask': PadDataset(
                        img_gpt_input_mask,
                        pad_idx=0,
                        left_pad=False,
                    ),
                    'img_attention_masks': PadDataset(
                        img_attention_masks,
                        pad_idx=0,
                        left_pad=False,
                    ),
                    # 'chunk_tokens': PadDataset(
                    #     chunk_tokens,
                    #     pad_idx=0,
                    #     left_pad=False,
                    # ),
                    'segment_tokens': PadDataset(
                        segment_tokens,
                        pad_idx=0,
                        left_pad=False,
                    ),
                    "image_paths": customDataset(
                        image_paths,
                    ),
                    'widths': customDataset(
                        widths,
                    ),
                    'heights': customDataset(
                        heights,
                    ),
                    "src_lengths": NumelDataset(src_dataset, reduce=False),
                },
                "target": PadDataset(
                    tgt_dataset, pad_idx=self.source_dictionary.pad(), left_pad=False
                ),
            },
            sizes=[np.array(src_lengths)],
        )

        Generate batches for inference. We prepend an eos token to src_tokens
        (or bos if `--add-bos-token` is set) and we append a <pad> to target.
        This is convenient both for generation with a prefix and LM scoring.
        
kosmos-2.5/kosmos2_5/tasks/generation.py