code: def test_exp_over_1_plus_exp(self):
      m = self.get_mode(excluding=["local_elemwise_fusion"])
  
      x = T.vector()
      data = np.random.rand(54).astype(config.floatX)
  
      backup = config.warn.identify_1pexp_bug
      config.warn.identify_1pexp_bug = False
      try:
          # tests exp_over_1_plus_exp
          f = theano.function([x], T.exp(x) / (1 + T.exp(x)), mode=m)
          assert [node.op for node in f.maker.fgraph.toposort()] == [
              sigmoid
          ]
          f(data)
          f = theano.function([x], T.exp(x) / (2 + T.exp(x)), mode=m)
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid
          ]
          f(data)
          f = theano.function([x], T.exp(x) / (1 - T.exp(x)), mode=m)
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid
          ]
          f(data)
          f = theano.function(
              [x], T.exp(x + 1) / (1 + T.exp(x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid
          ]
          f(data)
  
          # tests inv_1_plus_exp
          f = theano.function(
              [x], T.fill(x, 1.0) / (1 + T.exp(-x)), mode=m
          )
          # todo: solve issue #4589 first
          # assert check_stack_trace(f, ops_to_check=sigmoid)
          assert [node.op for node in f.maker.fgraph.toposort()] == [
              sigmoid
          ]
          f(data)
          f = theano.function(
              [x], T.fill(x, 1.0) / (2 + T.exp(-x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid
          ]
          f(data)
          f = theano.function(
              [x], T.fill(x, 1.0) / (1 - T.exp(-x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid
          ]
          f(data)
          f = theano.function(
              [x], T.fill(x, 1.1) / (1 + T.exp(-x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid
          ]
          f(data)
  
          # tests inv_1_plus_exp with neg
          f = theano.function(
              [x], T.fill(x, -1.0) / (1 + T.exp(-x)), mode=m
          )
          # todo: solve issue #4589 first
          # assert check_stack_trace(
          #     f, ops_to_check=[sigmoid, theano.tensor.inplace.neg_inplace])
          assert [node.op for node in f.maker.fgraph.toposort()] == [
              sigmoid,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x], T.fill(x, -1.0) / (1 - T.exp(-x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x], T.fill(x, -1.0) / (2 + T.exp(-x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x], T.fill(x, -1.1) / (1 + T.exp(-x)), mode=m
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
  
          # tests double inv_1_plus_exp with neg
          # (-1)(exp(x)) / (1+exp(x))(1+exp(-x))
          # = (-1)/(1+exp(-x)) * exp(x)/(1+exp(x))
          # = - (sigm(x) * sigm(x))
          f = theano.function(
              [x],
              (T.fill(x, -1.0) * T.exp(x))
              / ((1 + T.exp(x)) * (1 + T.exp(-x))),
              mode=m,
          )
          # todo: solve issue #4589 first
          # assert check_stack_trace(f, ops_to_check=[sigmoid, T.mul])
          assert [node.op for node in f.maker.fgraph.toposort()] == [
              sigmoid,
              T.mul,
          ]
          f(data)
          f = theano.function(
              [x],
              (T.fill(x, -1.1) * T.exp(x))
              / ((1 + T.exp(x)) * (1 + T.exp(-x))),
              mode=m,
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              T.mul,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x],
              (T.fill(x, -1.0) * T.exp(x))
              / ((2 + T.exp(x)) * (1 + T.exp(-x))),
              mode=m,
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              T.mul,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x],
              (T.fill(x, -1.0) * T.exp(x))
              / ((1 + T.exp(x)) * (2 + T.exp(-x))),
              mode=m,
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              T.mul,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x],
              (T.fill(x, -1.0) * T.exp(x))
              / ((1 + T.exp(x)) * (1 + T.exp(x))),
              mode=m,
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              T.mul,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
          f = theano.function(
              [x],
              (T.fill(x, -1.0) * T.exp(x))
              / ((1 + T.exp(x)) * (2 + T.exp(-x))),
              mode=m,
          )
          assert [node.op for node in f.maker.fgraph.toposort()] != [
              sigmoid,
              T.mul,
              theano.tensor.inplace.neg_inplace,
          ]
          f(data)
  
      finally:
          # Restore config option.
          config.warn.identify_1pexp_bug = backup
  
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 2 for calling the T_sigmoid_opts obj's underlying member method code with example usage: obj.test_exp_over_1_plus_exp() without return types