Thank you for the suggestion, @ptrblck.
Here is my CustomExample following the first example in this link 1 you suggested.
template <typename Data = torch::Tensor, typename Path = std::string>
struct CustomExample {
    using DataType = Data;
    using PathType = Path;

    CustomExample() = default;
    CustomExample(Data data, Path path)
        : data(std::move(data)), path(std::move(path)) {}

    operator Data&() { return data; }
    operator const Data&() const { return data; }

    operator Path&() { return path; }
    operator const Path&() const { return path; }

    Data data;
    Path path;
};

When I replace, however,
torch::data::Example<> get(size_t index) override;

with
CustomExample<> get(size_t index) override;

I got below errors:
.../dataset.hpp(76): error: return type is neither identical to nor covariant with return type "torch::data::Example<at::Tensor, at::Tensor>" of overridden virtual function "torch::data::datasets::Dataset<Self, SingleExample>::get [with Self=sas::dlx::CustomDataset, SingleExample=torch::data::Example<at::Tensor, at::Tensor>]"
      CustomExample<> get(size_t index) override;
                      ^

.../dataset.hpp(76): error: member function declared with "override" does not override a base class member
      CustomExample<> get(size_t index) override;

Where my get() is part of
class CustomDataset : public torch::data::Dataset<CustomDataset>{...}

I guess the base class torch::data::Dataset<> has the preset get() member signature so that any inherited class has to maintain the same get() signature. If this is true, is there a way to register a different “get()” function to the torch dataloader?