//  [python]
def apply_unary_operation(self, mtx, uop, feat_dim):
        # identity, square, 2, -, -2, inv, centralize
        if uop == IDENTITY:
            ans = mtx
        elif uop == SQUARE:
            ans = mtx ** 2
        elif uop == DOUBLE:
            ans = 2 * mtx
        elif uop == NEGATIVE:
            ans = -mtx
        # elif uop == 4:
        #     ans = -2 * mtx
        # no inverse operation here
        elif uop == INVERSE:
            with torch.no_grad():
                if len(feat_dim) == 1:
                    # todo: verify the effectiveness of the pinverse operation on [k x 1]-dim tensor --- what's the resulting tensor's dimension?
                    # Fature dimension remains not influenced
                    norm_2 = torch.norm(mtx, dim=-1, keepdim=True, p=2)
                    ans = mtx / torch.clamp(norm_2 ** 2, min=1e-9)
                    # ans = mtx.unsqueeze(-1)
                    # ans = torch.pinverse(ans)
                    # ans = ans.squeeze(-2)
                elif len(feat_dim) == 2:
                    # ans = torch.pinverse(mtx)
                    # ans = torch.linalg.pinv(mtx)
                    with torch.no_grad():
                        u, s, vh = np.linalg.svd(mtx.detach().cpu().numpy())
                    u = torch.from_numpy(u).cuda()
                    vh = torch.from_numpy(vh).cuda()
                    s = torch.from_numpy(s).cuda()

                    # s = torch.linalg.pinv(s)
                    s_norm_2 = torch.norm(s, dim=-1, keepdim=True, p=2)
                    s = s / torch.clamp(s_norm_2 ** 2, min=1e-9)
                    # ans = torch.matmul(torch.matmul(u, s), vh)
                    v = vh.contiguous().transpose(-1, -2).contiguous()
                    uh = u.contiguous().transpose(-1, -2).contiguous()
                    # ans = torch.matmul(v, torch.matmul(s, uh))
                    # print(v.size(), s.size(), uh.size()); s.size = bz x N x 3
                    # ans = torch.matmul(v * s.unsqueeze(-1), uh)
                    # right multiplication modifies column vectors
                    ans = torch.matmul(v * s.unsqueeze(-2), uh)
                    feat_dim = list(reversed(feat_dim))
                else:
                    raise ValueError(f"Illegal matrix feature dimension: {feat_dim}.")
        elif uop == ORTHOGONIZE:
            # ONLY feature space orthogonization
            if len(feat_dim) == 1:
                # then then orthogonal operation is reduced to normalization
                ans = torch.div(mtx, torch.clamp(torch.norm(mtx, dim=-1, p=2, keepdim=True), min=1e-9))
            elif len(feat_dim) == 2:
                with torch.no_grad():
                    u, s, vh = np.linalg.svd(mtx.detach().cpu().numpy())
                u = torch.from_numpy(u).cuda()
                vh = torch.from_numpy(vh).cuda()
                # todo: any other situation beyond these two?
                if len(u.size()) == 4:
                    u = u[:, :, :, :feat_dim[-1]]
                elif len(u.size()) == 5:
                    u = u[:, :, :, :, :feat_dim[-1]]
                else:
                    raise ValueError(f"Uncorrect u.size() = {u.size()}.")
                ans = torch.matmul(u, vh)
            else:
                raise ValueError(f"Uncorrect feat_dim.len = {len(feat_dim)}")
        elif uop == CENTRALIZE:
            if len(feat_dim) == 1 and len(mtx.size()) == 4:
                ans = mtx - torch.mean(mtx, dim=2, keepdim=True)
            else:
                ans = mtx
        else:
            raise ValueError(f"Unrecognized uop: {uop}")
        return ans, feat_dim