def intrinsic_key_maps(self):
        """
        Returns the intrinsic key, tensor_index_map and index_tensor_map
        for the purpose of identifying a optree. The key is depended on the ops
        tensors dimensions and the relaion among the tensors.

        x0 * x1 + x0 * x2 will have the same intrinsic key as y0 * y1 + y0 * y2,
        if xi and yi have the same shape.

        In tensor_index_map and index_tensor_map, tensors has a one-to-one
        mapping with indices. The index of the tensor is depended on the first
        occurance of the tensor in the post-order traversal of the optree.

        Returns:
            (intrinsic_key, tensor_index_map, index_tensor_map)

        """
        stack = self.traverse(list())
        tensor_index = 0
        tensor_index_map = {}
        index_tensor_map = {}
        for i in range(len(stack)):
            if type(stack[i]) is dict:
                if 'axis' in stack[i]:
                    stack[i] = (stack[i]['op'], stack[i]['axis'])
                else:
                    stack[i] = (stack[i]['op'])
            elif isinstance(stack[i], Tensor):
                # use interger to replace tensor
                if stack[i] in tensor_index_map:
                    stack[i] = (tensor_index_map[stack[i]], stack[i].shape)
                else:
                    # put tensor in dict
                    tensor_index_map[stack[i]] = tensor_index
                    index_tensor_map[tensor_index] = stack[i]
                    stack[i] = (tensor_index, stack[i].shape)
                    tensor_index += 1

        return (tuple(stack), tensor_index_map, index_tensor_map)
dataset/ETHPy150Open NervanaSystems/neon/neon/backends/backend.py/OpTreeNode.intrinsic_key_maps/original