code: def test_set_backend():
      torch = pytest.importorskip("torch")
  
      toplevel_backend = tl.get_backend()
  
      # Set in context manager
      with tl.backend_context("numpy"):
          assert tl.get_backend() == "numpy"
          assert isinstance(tl.tensor([1, 2, 3]), np.ndarray)
          assert isinstance(T.tensor([1, 2, 3]), np.ndarray)
          assert tl.float32 is T.float32 is np.float32
  
          with tl.backend_context("pytorch"):
              assert tl.get_backend() == "pytorch"
              assert torch.is_tensor(tl.tensor([1, 2, 3]))
              assert torch.is_tensor(T.tensor([1, 2, 3]))
              assert tl.float32 is T.float32 is torch.float32
  
          # Sets back to numpy
          assert tl.get_backend() == "numpy"
          assert isinstance(tl.tensor([1, 2, 3]), np.ndarray)
          assert isinstance(T.tensor([1, 2, 3]), np.ndarray)
          assert tl.float32 is T.float32 is np.float32
  
      # Reset back to initial backend
      assert tl.get_backend() == toplevel_backend
  
      # Set not in context manager
      tl.set_backend("pytorch")
      assert tl.get_backend() == "pytorch"
      tl.set_backend(toplevel_backend)
  
      assert tl.get_backend() == toplevel_backend
  
      # Improper name doesn't reset backend
      with assert_raises(ValueError):
          tl.set_backend("not-a-real-backend")
      assert tl.get_backend() == toplevel_backend
  
imports: from concurrent.futures import ThreadPoolExecutor
  import pytest
  from time import time
  import numpy
  from scipy.linalg import svd
  from scipy import special
  import tensorly
  from ..None import backend
  from ..testing import assert_allclose, assert_array_equal, assert_equal, assert_, assert_array_almost_equal, assert_raises
  from tensorly.tenalg.svd import SVD_FUNS, svd_interface
label_desc: Use image node_id 1 for calling a global function with example usage: test_set_backend() without return types