def resource_path_id(path: tuple[str, ...]) -> int:
        """Computes the index of a path in diff.groups."""
        idx = resource_groups_index.get(path, None)
        if idx is not None:
            return idx
        # Recursive call to get the assigned index of the parent. Note the base case
        # of the empty path, which returns _EMPTY_RESOURCE_PATH_IDX.
        parent_id = resource_path_id(path[:-1])
        # This path has not been seen. It will be appended to diff.groups, with idx as
        # the size of diff.groups before appending.
        idx = len(diff.groups)
        diff.groups.add(parent=parent_id, name=token_id(path[-1]))
        resource_groups_index[path] = idx
        return idx
Computes the index of a path in diff.groups.
cirq-google/cirq_google/api/v2/run_context.py