code: def test_local_sigm_times_exp(self):
      # Test the `local_sigm_times_exp` optimization.
      # exp(x) * sigm(-x) -> sigm(x)
      # exp(-x) * sigm(x) -> sigm(-x)
  
      def match(func, ops):
          # print [node.op.scalar_op for node in func.maker.fgraph.toposort()]
          assert [
              node.op for node in func.maker.fgraph.toposort()
          ] == ops
  
      m = self.get_mode(excluding=["local_elemwise_fusion", "inplace"])
      x, y = tensor.vectors("x", "y")
  
      f = theano.function([x], sigmoid(-x) * tensor.exp(x), mode=m)
      match(f, [sigmoid])
      assert check_stack_trace(f, ops_to_check=sigmoid)
  
      f = theano.function([x], sigmoid(x) * tensor.exp(-x), mode=m)
      match(f, [tensor.neg, sigmoid])
      assert check_stack_trace(f, ops_to_check=sigmoid)
  
      f = theano.function(
          [x], -(-(-(sigmoid(x)))) * tensor.exp(-x), mode=m
      )
      match(f, [tensor.neg, sigmoid, tensor.neg])
      # assert check_stack_trace(f, ops_to_check=sigmoid)
  
      f = theano.function(
          [x, y],
          (
              sigmoid(x)
              * sigmoid(-y)
              * -tensor.exp(-x)
              * tensor.exp(x * y)
              * tensor.exp(y)
          ),
          mode=m,
      )
      topo = f.maker.fgraph.toposort()
      for op, nb in [
          (sigmoid, 2),
          (tensor.mul, 2),
          (tensor.neg, 1),
          (tensor.exp, 1),
      ]:
          assert sum([n.op == op for n in topo]) == nb
  
imports: from __future__ import absolute_import, print_function, division
  import unittest
  import numpy
  from theano.compat import imap
  import theano.tensor.inplace
  from theano.tensor import basic
  from theano import tensor
  from theano import config
  from theano.gof.opt import check_stack_trace
  from theano.tests import unittest_tools
  from theano.tensor.nnet import sigmoid, sigmoid_inplace, softplus, ultra_fast_sigmoid, hard_sigmoid
  from theano.tensor.nnet.sigm import compute_mul, is_1pexp, parse_mul_tree, perform_sigm_times_exp, register_local_1msigmoid, simplify_mul
  from theano.tensor.tests.test_basic import makeBroadcastTester, copymod, check_floatX, upcast_int8_nfunc, _good_broadcast_unary_normal_no_complex
label_desc: Use image node_id 4 for calling the T_sigmoid_opts obj's underlying member method code with example usage: obj.test_local_sigm_times_exp() without return types