I decided to use an alternative method shown below:
###im_paths = torch.Tensor()
im_paths = []
with torch.no_grad():
    for i, (inputs, classes, im_path) in enumerate(dataloaders['test']):
       
        ###im_paths = torch.cat((im_paths, im_path), )
        im_paths.append(im_path)

flattened_im_paths = flattened = [item for sublist in im_paths for item in sublist]

now flattened_im_paths does the deed.
Last line is from https://stackoverflow.com/a/51291027/2414957 579