code: def test_grad_inrange():
      for bound_definition in [(True, True), (False, False)]:
          # Instantiate op, and then take the gradient
          op = InRange(*bound_definition)
          x = fscalar("x")
          low = fscalar("low")
          high = fscalar("high")
          out = op(x, low, high)
          gx, glow, ghigh = pytensor.gradient.grad(out, [x, low, high])
  
          # We look if the gradient are equal to zero
          # if x is lower than the lower bound,
          # equal to the lower bound, between lower and higher bound,
          # equal to the higher bound and higher than the higher
          # bound.
          # Mathematically we should have an infinite gradient when
          # x is equal to the lower or higher bound but in that case
          # PyTensor defines the gradient to be zero for stability.
          f = pytensor.function([x, low, high], [gx, glow, ghigh])
          utt.assert_allclose(f(0, 1, 5), [0, 0, 0])
          utt.assert_allclose(f(1, 1, 5), [0, 0, 0])
          utt.assert_allclose(f(2, 1, 5), [0, 0, 0])
          utt.assert_allclose(f(5, 1, 5), [0, 0, 0])
          utt.assert_allclose(f(7, 1, 5), [0, 0, 0])
  
imports: import numpy
  import pytest
  import pytensor
  import pytensor.tensor
  import tests.unittest_tools
  from pytensor.compile.mode import Mode
  from pytensor.graph.fg import FunctionGraph
  from pytensor.link.c.basic import DualLinker
  from pytensor.scalar.basic import ComplexError, Composite, InRange, ScalarType, add, and_, arccos, arccosh, arcsin, arcsinh, arctan, arctan2, arctanh, cast, complex64, constant, cos, cosh, deg2rad, eq, exp, exp2, expm1, float16, float32, floats, int8, int32, ints, invert, log, log1p, log2, log10, mean, mul, neq, rad2deg, reciprocal, sin, sinh, sqrt, switch, tan, tanh, true_div, uint8
  from pytensor.tensor.type import fscalar, imatrix, iscalar, matrix
  from tests.link.test_link import make_function
label_desc: Use image node_id 6 for calling a global function with example usage: test_grad_inrange() without return types