human
Complete this python program:
def elemwise_checker(op, expected_f, gap=None, test_dtypes=None, grad_test=True, name=None, gap_grad=None):
assistant
#Here is the Python code you requested.

    """Return the appropriate test class for the elemwise on sparse.
    :param op: Op to test.
    :expected_f: Function use to compare. This function must act
    on dense matrix. If the op is structured
    see the `structure_function` decorator to make
    this function structured.
    :param gap: Tuple for the range of the random sample. When
    length is 1, it is assumed to be the exclusive
    max, when `gap` = (`a`, `b`) it provide a sample
    from [a, b[. If `None` is used, it provide [0, 1]
    for float dtypes and [0, 50[ for integer dtypes.
    :param test_dtypes: Particular dtypes for testing the op.
    If `None`, this is set to the most common
    dtypes.
    :param grad_test: True for testing the grad. False will
    skip this test.
    :param gap_grad: If None, we reuse gap. Otherwise it is the same as gap
    but for testing the gradiant of the op.
    :return: The class that perform the tests, not an instance
    of the class.
    """
    if (test_dtypes is None):
        test_dtypes = sparse.all_dtypes
    class Tester(unittest.TestCase, ):
        def setUp(self):
            super(Tester, self).setUp()
            self.op = op
            self.expected_f = expected_f
            self.gap = gap
            if (gap_grad is not None):
                self.gap_grad = gap_grad
            else:
                self.gap_grad = gap
            utt.seed_rng()
            assert (eval(self.__class__.__name__) is self.__class__)
        def test_op(self):
            for format in sparse.sparse_formats:
                for dtype in test_dtypes:
                    if ((dtype == 'int8') or (dtype == 'uint8')):
                        continue
                    if dtype.startswith('uint'):
                        if (self.gap and (len(self.gap) == 2) and (self.gap[0] < 0)):
                            if (self.gap[1] >= 1):
                                self.gap = (0, self.gap[1])
                            else:
                                raise TypeError('Gap    not    suitable    for', dtype, self.__name__)
                    (variable, data) = sparse_random_inputs(format, shape=(4, 7), out_dtype=dtype, gap=self.gap)
                    f = theano.function(variable, self.op(*variable))
                    tested = f(*data)
                    data = [m.toarray() for m in data]
                    expected = self.expected_f(*data)
                    assert (tested.format == format)
                    tested = tested.toarray()
                    try:
                        utt.assert_allclose(expected, tested)
                    except AssertionError:
                        raise AssertionError(self.__name__)
                for dtype in ['int8', 'uint8']:
                    if (dtype in test_dtypes):
                        if self.gap:
                            domain = self.gap
                            if (dtype == 'uint8'):
                                if ((len(domain) == 2) and (domain[0] < 0)):
                      ...