def sg_int(tensor, opt):
    r"""Casts a tensor to intx.
    
    See `tf.cast()` in tensorflow.

    Args:
      tensor: A `Tensor` or `SparseTensor` (automatically given by chain).
      opt:
        name: If provided, it replaces current tensor's name.

    Returns:
      A `Tensor` or `SparseTensor` with same shape as `tensor`.
    """
    return tf.cast(tensor, tf.sg_intx, name=opt.name)