# Path: tf_slim/layers/sparse_ops.py
# def _multiplier_helper(shape):
# def _ignore_value_tensor(dtype, ignore_value=None):
# def dense_to_sparse_tensor(dense_tensor, ignore_value=None):
# def indicators_to_sparse_ids(indicators, ignore_value=None, dtype=dtypes.int64):
# def sparse_row_envelope(sparse_input, row_axis=0, col_axis=1, name=None):


import numpy as np
import tensorflow.compat.v1 as tf
from tf_slim.layers import sparse_ops
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import sparse_tensor
from tensorflow.python.ops import array_ops
from tensorflow.python.platform import test
"""Tests for tf_slim.ops.sparse_ops."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


# pylint: disable=g-direct-tensorflow-import


def setUpModule():
  tf.disable_eager_execution()


def _assert_sparse_tensor_value(test_case, expected, actual):
  test_case.assertEqual(np.int64, np.array(actual.indices).dtype)
  test_case.assertAllEqual(expected.indices, actual.indices)

  test_case.assertEqual(
      np.array(expected.values).dtype, np.array(actual.values).dtype)
  test_case.assertAllEqual(expected.values, actual.values)

  test_case.assertEqual(np.int64, np.array(actual.dense_shape).dtype)
  test_case.assertAllEqual(expected.dense_shape, actual.dense_shape)


class DenseToSparseTensorTest(test.TestCase):

  def test_dense_to_sparse_tensor_1d(self):
    with self.cached_session() as sess:

# Path: tf_slim/layers/sparse_ops.py
# def _multiplier_helper(shape):
# def _ignore_value_tensor(dtype, ignore_value=None):
# def dense_to_sparse_tensor(dense_tensor, ignore_value=None):
# def indicators_to_sparse_ids(indicators, ignore_value=None, dtype=dtypes.int64):
# def sparse_row_envelope(sparse_input, row_axis=0, col_axis=1, name=None):


# Path: tf_slim/layers/sparse_ops_test.py
import numpy as np
import tensorflow.compat.v1 as tf
from tf_slim.layers import sparse_ops
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import sparse_tensor
from tensorflow.python.ops import array_ops
from tensorflow.python.platform import test

"""Tests for tf_slim.ops.sparse_ops."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


# pylint: disable=g-direct-tensorflow-import


def setUpModule():
  tf.disable_eager_execution()


def _assert_sparse_tensor_value(test_case, expected, actual):
  test_case.assertEqual(np.int64, np.array(actual.indices).dtype)
  test_case.assertAllEqual(expected.indices, actual.indices)

  test_case.assertEqual(
      np.array(expected.values).dtype, np.array(actual.values).dtype)
  test_case.assertAllEqual(expected.values, actual.values)

  test_case.assertEqual(np.int64, np.array(actual.dense_shape).dtype)
  test_case.assertAllEqual(expected.dense_shape, actual.dense_shape)


class DenseToSparseTensorTest(test.TestCase):

  def test_dense_to_sparse_tensor_1d(self):
    with self.cached_session() as sess:

      st = sparse_ops.dense_to_sparse_tensor([1, 0, 2, 0])