if (cnum - len(path)) == -1:
idx_result = output_subscript
else:
sort_result = [(dimension_dict[ind], ind) for ind in out_inds]
idx_result = "".join([x[1] for x in sorted(sort_result)])
shp_result = parser.find_output_shape(tmp_inputs, tmp_shapes, idx_result)
input_list.append(idx_result)
After Change
else:
// use tensordot order to minimize transpositions
all_input_inds = "".join(tmp_inputs)
idx_result = "".join(sorted(out_inds, key=all_input_inds.find))
shp_result = parser.find_output_shape(tmp_inputs, tmp_shapes, idx_result)
input_list.append(idx_result)