# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/test_utils.ipynb.

# %% auto 0
__all__ = ['TEST_AUDIO', 'TEST_IMAGE', 'tst_param', 'tst_params', 'test_fail', 'test', 'nequals', 'test_eq', 'test_eq_type',
           'test_ne', 'is_close', 'test_close', 'test_is', 'test_shuffled', 'test_stdout', 'test_warns',
           'test_fig_exists', 'ExceptionExpected', 'exception', 'synth_dbunch', 'RegModel', 'synth_learner',
           'VerboseCallback', 'get_env', 'try_import', 'nvidia_smi', 'nvidia_mem', 'test_show_install', 'less_random']

# %% ../nbs/test_utils.ipynb 2
from fastcore.test import (test_fail, test, nequals, test_eq, test_eq_type, test_ne,
                           is_close, test_close, test_is, test_shuffled, test_stdout,
                           test_warns, TEST_IMAGE, test_fig_exists, ExceptionExpected, exception)

from fastcore.foundation import L
from fastai.torch_core import tensor
from fastai.test_utils import synth_dbunch, synth_learner, RegModel, VerboseCallback, get_env, try_import, nvidia_smi, nvidia_mem
from fastai.test_utils import show_install as test_show_install
from .utils import less_random

# %% ../nbs/test_utils.ipynb 4
_all_ = ['test_fail', 'test', 'nequals', 'test_eq', 'test_eq_type', 'test_ne', 'is_close', 'test_close', 'test_is', 'test_shuffled', 'test_stdout', 'test_warns', 'TEST_IMAGE', 'test_fig_exists', 'ExceptionExpected', 'exception',  'synth_dbunch', 'RegModel', 'synth_learner', 'VerboseCallback', 'get_env', 'try_import', 'nvidia_smi', 'nvidia_mem', 'test_show_install', 'less_random']

# %% ../nbs/test_utils.ipynb 5
TEST_AUDIO = 'audio/whistle.wav'
TEST_IMAGE = 'images/puppy.jpg'

# %% ../nbs/test_utils.ipynb 7
def tst_param(val, grad=None):
    "Create a tensor with `val` and a gradient of `grad` for testing"
    res = tensor([val]).float()
    res.grad = tensor([val/10 if grad is None else grad]).float()
    return res

# %% ../nbs/test_utils.ipynb 8
def tst_params():
    r = L.range(4)
    return r.map(tst_param)
