# Operator products summing

Is there a way to perform the below summation in Mathematica?

$$\frac{\left(\hat{X}_{ij}+i\delta_{ij}\right)}{i}\frac{\left(\hat{X}_{kl}+i\delta_{kl}\right)}{i}$$

I am finding the issue because order matters here. X is operator. So it’s order is important. g and X are antisymmetric tensors. The answer to the above equation I am expecting is:

$$-\sum_{i,j,k,l}\left(g_{ijkl}\hat{X}_{ij}\hat{X}_{kl}+ig_{ijkl}\hat{X}_{ij}\delta_{kl}+ig_{ijkl}\delta_{ij}\hat{X}_{kl}-g_{ijkl}\delta_{ij}\delta_{kl}\right)$$ $$=-\sum_{i,j,k,l}g_{ijkl}\hat{X}_{ij}\hat{X}_{kl}$$

Can I implement this using the following code:

SumHeld /: MakeBoxes[SumHeld[expr_, ranges__], form_] :=   MakeBoxes[Sum[expr, ranges], form]  SumHeld /:    SyntaxInformation[    SumHeld] = {"LocalVariables" -> {"Table", {2, Infinity}}}; SumHeld /: c_?NumericQ SumHeld[rest_, range__] :=   SumHeld[c rest, range] IndexUnify[HoldPattern@Plus[sums : SumHeld[_, __] ..]] :=   Plus @@ With[{targetIndices = List @@ #[[-1, 2 ;;, 1]],        sourceIndicesList = List @@@ #[[;; , 2 ;;, 1]]},       Function[{sum, sourceIndices},         sum /. Thread[          sourceIndices ->            Take[targetIndices, Length@sourceIndices]]] @@@        Transpose@{#, sourceIndicesList}] &@   SortBy[Flatten /@ {sums}, Length]  SumTogether[HoldPattern@Plus[sums : SumHeld[_, sameRanges__] ..]] :=   SumHeld[Plus @@ {sums}[[;; , 1]], sameRanges] SumTogether[HoldPattern@Plus[sums : SumHeld[_, __] ..]] /;    UnsameQ @@ {sums}[[;; , 2 ;;]] :=   Plus @@ SumTogether@*Plus @@@ GatherBy[{sums}, Rest]  SumHeld[expr_, {lst_List,     dim_}] := (term |->      SumHeld[term,       Sequence @@        Table[If[Count[term, patt, \[Infinity]] == 2, {patt, dim},          Nothing], {patt, lst}]]) /@ expr 

How to modify the above code to incorporate to handle operators?