Is it possible to get dataset file infromation at the time of test a model?
My dataset code is like the below one; Here, X_test is a list[list] and y_test is list[Path]
The first.py file
self.test_dataset = LongDataset(
                X_path=X_test,
                y_path=y_test,
                transform=val_transforms,
            )

The rest of the part is as usual (dataloader)
def test_dataloader(self):
        return DataLoader(self.test_dataset, batch_size=1, num_workers=8)

In the second.py file
The DataModule
data_module = DataModuleLong(batch_size=3,)

The Trainer
trainer = Trainer(gpus=1)
    trainer.test(
        model=model,
        ckpt_path=ckpt_path,
        datamodule=data_module,
    )

The  train_step() in the third.py file
def test_step(self, batch, batch_idx: int):
        inputs, targets = batch
        logits = self(inputs)
        ...
        ...
        ...

Now, is it possible to print (in the train_step()) the (inputs, targets) filename (or the full path) I am sending from test_dataset as (X_path, y_path)?

Essentially, what you want to do is get the index of each batch element in the batch returned by the dataloader object (from there it is trivial to index the dataset to get the desired data elements (in this case file paths).
Now the short answer is that there is no directly implemented way to return this data using the dataloader. However, there are a few workarounds:

Pass your own BatchSampler or Sampler object to the DataLoader constructor. Unfortunately there's not a simple way to query the Sampler for the current batch because it relies on generators (where yielding the next sample clears it and loades the next one. This is the same reason why you can't directly access the batch indices of the Dataloader. So to use this method, you'd have to pass a sampler wherein you know a priori which indices will be returned on the i-th query to the sampler. Not an ideal solution.

Create a custom dataset object - this is actually extremely easy to do, simply inherit from the torch.data object and implement the __init__, __len__ and __getitem__ methods. The __getitem__ method takes an index (let's say idx) as input and returns that index of the dataset. You can essentially copy the code for the existing LongDataset line for line, but simply append idx to the returned values from the __getitem__ method. I would demonstrate but you don't indicate where the LongDataset code comes from.
def __getitem__(self,idx):
    ... #load files, preprocess, etc.
    return data, idx

Now dataloader will automatically zip the idx values for each, so you can simply replace the existing line with:
inputs, targets, indices = batch
data_paths = [self.test_dataset.file_paths[idx] for idx in indices]



The second solution is by far preferable as it is more transparently easy to understand.
