def _is_1(expr):
 try:
  v = opt.get_scalar_constant_value(expr)
  return numpy.allclose(v, 1)
 except tensor.NotScalarConstantError:
  return False

def _is_1 ( expr ) : try : v = opt . get_scalar_constant_value ( expr ) return numpy . allclose ( v , 1 ) except tensor . NotScalarConstantError : return False
returns bool true iff expr is a constant close to 1 .