def unstack(value, num: nil, axis: 0, name: "unstack")
      res = _op(:unstack, value, num: num, axis: axis, name: name)

      num_vars = if value.shape.known?
        new_shape = value.shape.shape.dup
        rank = new_shape.size - 1
        axis = rank + axis if axis < 0
        rotated_shape = Array.new(axis + 1) { new_shape.shift }
        new_shape = rotated_shape.rotate!(-1) + new_shape
        new_shape[0]
      else
        raise TensorStream::ValueError, "num is unspecified and cannot be inferred." if num.nil?

        num
      end

      return res[0] if num_vars == 1

      Array.new(num_vars) do |i|
        index(res, i, name: "unstack/index:#{i}")
      end
    end
def unstack(value, num: nil, axis: 0, name: "unstack")
      res = _op(:unstack, value, num: num, axis: axis, name: name)

      num_vars = if value.shape.known?
        new_shape = value.shape.shape.dup
        rank = new_shape.size - 1
        axis = rank + axis if axis < 0
        rotated_shape = Array.new(axis + 1) { new_shape.shift }
        new_shape = rotated_shape.rotate!(-1) + new_shape
        new_shape[0]
      else
        raise TensorStream::ValueError, "num is unspecified and cannot be inferred." if num.nil?

        num
      end

      return res[0] if num_vars == 1

      Array.new(num_vars) do |i|
        index(res, i, name: "unstack/index:#{i}")
      end
    end
Unpacks the given dimension of a rank-R tensor into rank-(R-1) tensors.