@classmethod<EOL><INDENT>def sparse(cls, a_ndarray, i_ndarray, shape, bigdl_type="<STR_LIT:float>"):<DEDENT>
if a_ndarray is None:<EOL><INDENT>return None<EOL><DEDENT>assert isinstance(a_ndarray, np.ndarray),"<STR_LIT>" % type(a_ndarray)<EOL>assert isinstance(i_ndarray, np.ndarray),"<STR_LIT>" % type(a_ndarray)<EOL>assert i_ndarray.size == a_ndarray.size * shape.size,"<STR_LIT>"<EOL>return cls(a_ndarray,<EOL>shape,<EOL>bigdl_type,<EOL>i_ndarray)<EOL>
Convert a three ndarray to SparseTensor which would be used in Java side.
For example:
a_ndarray = [1, 3, 2, 4]
i_ndarray = [[0, 0, 1, 2],
             [0, 3, 2, 1]]
shape = [3, 4]
Present a dense tensor
[[ 1,  0,  0,  3],
 [ 0,  0,  2,  0],
 [ 0,  4,  0,  0]]

:param a_ndarray non-zero elements in this SparseTensor
:param i_ndarray zero-based indices for non-zero element
                 i_ndarray's shape should be (shape.size, a_ndarray.size)
                 And the i-th non-zero elements indices is i_ndarray[:, 1],
                 should be zero-based and ascending;
:param shape     shape as a DenseTensor.

>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> from bigdl.util.common import callBigDlFunc
>>> np.random.seed(123)
>>> data = np.arange(1, 7).astype("float32")
>>> indices = np.arange(1, 7)
>>> shape = np.array([10])
>>> result = JTensor.sparse(data, indices, shape)
>>> expected_storage = np.array([1., 2., 3., 4., 5., 6.])
>>> expected_shape = np.array([10])
>>> expected_indices = np.array([1, 2, 3, 4, 5, 6])
>>> np.testing.assert_allclose(result.storage, expected_storage)
>>> np.testing.assert_allclose(result.shape, expected_shape)
>>> np.testing.assert_allclose(result.indices, expected_indices)
>>> tensor1 = callBigDlFunc("float", "testTensor", result)  # noqa
>>> array_from_tensor = tensor1.to_ndarray()
>>> expected_ndarray = np.array([0, 1, 2, 3, 4, 5, 6, 0, 0, 0])
>>> (array_from_tensor == expected_ndarray).all()
True