code: def twofilter_smoothing(self, t, info, phi, loggamma, linear_cost=False,
                              return_ess=False, modif_forward=None,
                              modif_info=None):
          
          ti = self.T - 2 - t  # t+1 in reverse
          if t < 0 or t >= self.T - 1:
              raise ValueError(
                  'two-filter smoothing: t must be in range 0,...,T-2')
          lwinfo = info.hist.wgt[ti].lw - loggamma(info.hist.X[ti])
          if linear_cost:
              return self._twofilter_smoothing_ON(t, ti, info, phi, lwinfo,
                                                 return_ess,
                                                 modif_forward, modif_info)
          else:
              return self._twofilter_smoothing_ON2(t, ti, info, phi, lwinfo)
docs: Two-filter smoothing.
  
          Parameters
          ----------
          t: time, in range 0 <= t < T-1
          info: SMC object 
              the information filter
          phi: function
              test function, a function of (X_t,X_{t+1})
          loggamma: function
              a function of (X_{t+1})
          linear_cost: bool
              if True, use the O(N) variant (basic version is O(N^2))
  
          Returns
          -------
          Two-filter estimate of the smoothing expectation of phi(X_t,x_{t+1})