code: def is_neg(var):
      """
      Match a variable with the `-x` pattern.
  
      Parameters
      ----------
      var
          The Variable to analyze.
  
      Returns
      -------
      object
          `x` if `var` is of the form `-x`, or None otherwise.
  
      """
      apply = var.owner
      if not apply:
          return None
      # First match against `tensor.neg`.
      if apply.op == tensor.neg:
          return apply.inputs[0]
      # Then match against a multiplication by -1.
      if apply.op == tensor.mul and len(apply.inputs) >= 2:
          for idx, mul_input in enumerate(apply.inputs):
              try:
                  constant = opt.get_scalar_constant_value(mul_input)
                  is_minus_1 = np.allclose(constant, -1)
              except NotScalarConstantError:
                  is_minus_1 = False
              if is_minus_1:
                  # Found a multiplication by -1.
                  if len(apply.inputs) == 2:
                      # Only return the other input.
                      return apply.inputs[1 - idx]
                  else:
                      # Return the multiplication of all other inputs.
                      return tensor.mul(
                          *(
                              apply.inputs[0:idx]
                              + apply.inputs[idx + 1 :]
                          )
                      )
      # No match.
      return None
  
imports: from __future__ import absolute_import, print_function, division
  import warnings
  import numpy
  import theano
  from theano import config, gof, printing, scalar
  from theano.compat import imap
  from theano.printing import pprint
  from theano.tensor import basic
  from theano.tensor import elemwise, opt, NotScalarConstantError
  from theano.tensor.type import values_eq_approx_remove_inf
  from theano.gof.opt import copy_stack_trace
label_desc: Use image node_id 10 for calling a global function with example usage: is_neg(var) and returns: None, None, apply, apply, tensor