<commit_before>import unittest

import numpy

import cupy
from cupy import cutensor
from cupy.cuda import cutensor as ct
from cupy import testing


@unittest.skipUnless(cupy.cuda.cutensor_enabled, 'cuTensor is unavailable')
@testing.parameterize(
    {'dtype': numpy.float16, 'tol': 3e-3},
    {'dtype': numpy.float32, 'tol': 1e-6},
    {'dtype': numpy.float64, 'tol': 1e-12},
    {'dtype': numpy.complex64, 'tol': 1e-6},
    {'dtype': numpy.complex128, 'tol': 1e-12},
)
class TestCuTensor(unittest.TestCase):

    def setUp(self):
        self.a = testing.shaped_random(
            (20, 40, 30), cupy, self.dtype, seed=0)
        self.b = testing.shaped_random(
            (40, 30, 20), cupy, self.dtype, seed=1)
        self.c = testing.shaped_random(
            (30, 20, 40), cupy, self.dtype, seed=2)
        self.mode_a = ('y', 'z', 'x')<commit_msg>Import cutensor only when enabled<commit_after>import unittest

import numpy

import cupy
from cupy import testing

if cupy.cuda.cutensor_enabled:
    from cupy import cutensor
    from cupy.cuda import cutensor as ct


@testing.parameterize(
    {'dtype': numpy.float16, 'tol': 3e-3},
    {'dtype': numpy.float32, 'tol': 1e-6},
    {'dtype': numpy.float64, 'tol': 1e-12},
    {'dtype': numpy.complex64, 'tol': 1e-6},
    {'dtype': numpy.complex128, 'tol': 1e-12},
)
@unittest.skipUnless(cupy.cuda.cutensor_enabled, 'cuTensor is unavailable')
class TestCuTensor(unittest.TestCase):

    def setUp(self):
        self.a = testing.shaped_random(
            (20, 40, 30), cupy, self.dtype, seed=0)
        self.b = testing.shaped_random(
            (40, 30, 20), cupy, self.dtype, seed=1)
        self.c = testing.shaped_random(
            (30, 20, 40), cupy, self.dtype, seed=2)
        self.mode_a = ('y', 'z', 'x')
{'fraction_non_alphanumeric': 0.157271702367531, 'fraction_numerical': 0.0496054114994363, 'mean_word_length': 3.1666666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7129757', 'n_tokens_mistral': 694, 'n_tokens_neox': 641, 'n_words': 159}