@register_canonicalize
@register_specialize
@gof.local_optimizer([T.TensorFromScalar])
def local_tensor_scalar_tensor(node):
 if isinstance(node.op, T.TensorFromScalar):
  s = node.inputs[0]
  if (s.owner and isinstance(s.owner.op, T.ScalarFromTensor)):
   t = s.owner.inputs[0]
   return [t]

@ register_canonicalize @ register_specialize @ gof . local_optimizer ( [ T . TensorFromScalar ] ) def local_tensor_scalar_tensor ( node ) : if isinstance ( node . op , T . TensorFromScalar ) : s = node . inputs [ 0 ] if ( s . owner and isinstance ( s . owner . op , T . ScalarFromTensor ) ) : t = s . owner . inputs [ 0 ] return [ t ]
tensor_from_scalar(scalar_from_tensor(x)) -> x .