def _structuredRaggedSparseElement(self, structure, shapes, dtype, padded_shape):
    if (structure is None):
        dense_shape = np.maximum(np.amax(shapes, axis=0), padded_shape)
        values = []
        for shape in shapes:
            dense_to_sparse = self._make_dense_to_sparse_fn((len(shape) == 0))
            sparse = dense_to_sparse(array_ops.zeros(shape, dtype=dtype))
            padded_sparse = sparse_tensor.SparseTensor(sparse.indices, sparse.values, dense_shape)
            reshaped_sparse = sparse_ops.sparse_reshape(padded_sparse, array_ops.concat([np.array([1], dtype=np.int64), dense_shape], 0))
            values.append(reshaped_sparse)
        return sparse_ops.sparse_concat(0, values)
    else:
        return tuple([self._structuredRaggedSparseElement(substructure, shapes, dtype, padded_shape) for substructure in structure])
def _structuredRaggedSparseElement(self, structure, shapes, dtype, padded_shape):
    if (structure is None):
        dense_shape = np.maximum(np.amax(shapes, axis=0), padded_shape)
        values = []
        for shape in shapes:
            dense_to_sparse = self._make_dense_to_sparse_fn((len(shape) == 0))
            sparse = dense_to_sparse(array_ops.zeros(shape, dtype=dtype))
            padded_sparse = sparse_tensor.SparseTensor(sparse.indices, sparse.values, dense_shape)
            reshaped_sparse = sparse_ops.sparse_reshape(padded_sparse, array_ops.concat([np.array([1], dtype=np.int64), dense_shape], 0))
            values.append(reshaped_sparse)
        return sparse_ops.sparse_concat(0, values)
    else:
        return tuple([self._structuredRaggedSparseElement(substructure, shapes, dtype, padded_shape) for substructure in structure])