def get_output_path(self, input_path=None, output_ext=None):
        """Returns a unique output path.

        Args:
            input_path (None): an input path
            output_ext (None): an optional output extension to use

        Returns:
            the output path
        """
        if input_path:
            input_path = fos.normalize_path(input_path)

            if self.rel_dir is not None:
                input_path = safe_relpath(input_path, self.rel_dir)
            else:
                input_path = os.path.basename(input_path)

            input_path_sans_ext, input_ext = os.path.splitext(input_path)

            # URL handling
            # @todo improve this, while still maintaining Unix/Windows path
            # support
            input_path_sans_ext = input_path_sans_ext.replace("%", "-")
            input_ext = (
                output_ext
                if output_ext is not None
                else input_ext.split("?")[0]
            )

            input_path = input_path_sans_ext + input_ext
        else:
            input_path = str(uuid.uuid4()) + self.default_ext

        output_path = (
            os.path.join(self.output_dir, input_path)
            if self.output_dir
            else input_path
        )

        output_dir = os.path.dirname(output_path)
        output_name = os.path.basename(output_path)
        output_name_sans_ext, output_ext = os.path.splitext(output_name)

        last_attempted_output_number = None
        output_number = (
            self.starting_filepath_counts.get(
                (
                    os.path.splitext(output_path)[0]
                    if self.ignore_exts
                    else output_path
                ),
                0,
            )
            + 1
        )
        while True:
            # Add  file number to the output path with if necessary
            if output_number > 1:
                output_path = os.path.join(
                    output_dir,
                    output_name_sans_ext + f"-{output_number}" + output_ext,
                )

            try:
                # Attempt to create a placeholder file to show  the output
                # path has been claimed
                touch_filename = os.path.basename(output_path)

                if self.ignore_exts:
                    touch_filename, _ = os.path.splitext(touch_filename)

                touch_path = os.path.join(self.tmp_dir, touch_filename)
                with open(touch_path, "x", encoding="utf-8"):
                    ...

            except FileExistsError:
                # The output path has already been claimed with a placeholder

                if self.idempotent:
                    break

            else:
                # The output path was successfully claimed with a placeholder.
                break

            last_attempted_output_number = output_number

            touch_prefix = os.path.join(self.tmp_dir, output_name_sans_ext)
            touch_glob_pattern = glob.glob(glob.escape(touch_prefix) + "*")
            touch_re_pattern = re.escape(touch_prefix) + r"-(\d+).*"

            touch_paths = [
                f
                for f in touch_glob_pattern
                if self.ignore_exts or os.path.splitext(f)[0] == output_ext
            ]

            touched_number = None
            for touch_path in touch_paths:
                if m := re.match(touch_re_pattern, touch_path):
                    n = int(m.group(1))
                    if touched_number is None or n > touched_number:
                        touched_number = n

            if touched_number is None:
                touched_number = len(touch_paths)

            touched_number += 1

            output_number = (
                touched_number
                if touched_number > last_attempted_output_number
                else last_attempted_output_number + 1
            )

            logger.debug(
                "Temporary file already used: %s. Attempting to append -%s.",
                touch_path,
                output_number,
            )

        return output_path
Returns a unique output path.

        Args:
            input_path (None): an input path
            output_ext (None): an optional output extension to use

        Returns:
            the output path
        
fiftyone/core/utils.py