docstr: Generates a SparseTensor.
  
  Args:
    data: Should be a list of list of strings or int64. Each item of the outer
      list represents a batch. Each item of the batch is a feature of a
      specific feature column.
    batch_size: optional batch size, especially for cases when data has no
      entry for some batches.
  
  Returns:
   A SparseTensor.
docstr_tok: ["Generates","a","SparseTensor",".","Args",":","data",":","Should","be","a","list","of","list","of","strings","or","int64",".","Each","item","of","the","outer","list","represents","a","batch",".","Each","item","of","the","batch","is","a","feature","of","a","specific","feature","column",".","batch_size",":","optional","batch","size",",","especially","for","cases","when","data","has","no","entry","for","some","batches",".","Returns",":","A","SparseTensor","."]
code: def _sparse_tensor(self, data, batch_size=-1):
      """Generates a SparseTensor.
  
      Args:
        data: Should be a list of list of strings or int64. Each item of the outer
          list represents a batch. Each item of the batch is a feature of a
          specific feature column.
        batch_size: optional batch size, especially for cases when data has no
          entry for some batches.
  
      Returns:
       A SparseTensor.
      """
      indices = []
      values = []
      max_col_count = 0
      for batch, batch_ix in zip(data, range(len(data))):
          for column, column_ix in zip(batch, range(len(batch))):
              indices.append([batch_ix, column_ix])
              values.append(column)
              max_col_count = max(max_col_count, column_ix + 1)
      shape = [
          batch_size if batch_size != -1 else len(data),
          max_col_count,
      ]
      value_type = (
          dtypes.string
          if not values or isinstance(values[0], str)
          else dtypes.int64
      )
      return sparse_tensor.SparseTensor(
          constant_op.constant(
              indices, dtypes.int64, [len(indices), 2]
          ),
          constant_op.constant(values, value_type, [len(indices)]),
          constant_op.constant(shape, dtypes.int64),
      )
  
imports: import numpy
  from tensorflow.python.client import session
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_sparse_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the BaseSparseCrossOpTest obj's underlying member method code with example usage: obj._sparse_tensor(data, batch_size) and returns: sparse_tensor