    def _combine_sources(self, sources):
        """
        Combine multiple source files (given by path) into one
        source file and return the path of the combined file.

        Parameters
        ----------
        sources : Iterable[str]
            The list of paths to the source files to combine.

        Returns
        -------
        path : str
            The path to the combined source file.
        """
        assert len(sources) > 0, "Must have at least one source"
        if len(sources) == 1:
            # no need to combine a single source
            return next(iter(sources))

        file_lines = []
        for source in sources:
            with open(source, "r") as f:
                lines = f.readlines()
            for line in lines:
                if line.strip():
                    # collect the original non-empty lines
                    file_lines.append(line)
            # the last line might not end with "\n"
            file_lines.append("\n")

        # generate a new file name conditioned on the list of the source file names
        file_name = sha1((";".join(sorted(sources))).encode("utf-8")).hexdigest()
        file_dir = Path(next(iter(sources))).parents[0]  # fetch the directory
        file_path = file_dir / Path(f"temp_{file_name}.cu")
        with open(file_path, "w") as f:
            # file_lines end with "\n" already
            f.write("".join(file_lines))

        # return the path starting with "./"
        return os.path.join(".", str(file_path))
Combine multiple source files (given by path) into one
source file and return the path of the combined file.

Parameters
----------
sources : Iterable[str]
The list of paths to the source files to combine.

Returns
-------
path : str
The path to the combined source file.
python/aitemplate/backend/builder.py