code: def test_convert_to_torch():
      if torch.cuda.is_available():
          test_value = [torch.randn((2, 4))]
          out_value = convert_to_torch(
              test_value, device="cuda", cast=None, in_place=True
          )
          assert test_value is out_value
  
      test_value = [torch.randn((2, 4))]
      out_value = convert_to_torch(
          test_value, device=None, cast=torch.float64, in_place=True
      )
      assert test_value is out_value
  
      if torch.cuda.is_available():
          test_value = [torch.randn((2, 4))]
          out_value = convert_to_torch(
              test_value, device="cuda", cast=None, in_place="try"
          )
          assert test_value is out_value
  
      if torch.cuda.is_available():
          test_value = torch.randn((2, 4))
          with pytest.raises(Exception) as e_info:
              convert_to_torch(
                  test_value, device="cuda", cast=None, in_place=True
              )
  
      if torch.cuda.is_available():
          test_value = torch.randn((2, 4))
          out_value = convert_to_torch(
              test_value, device="cuda", cast=None, in_place="try"
          )
          assert test_value is not out_value
  
      test_value = torch.randn((2, 4))
      with pytest.raises(Exception) as e_info:
          convert_to_torch(
              test_value, device=None, cast=torch.float64, in_place=True
          )
  
file_path: maze/maze/test/perception/test_perception_utils.py
imports: import numpy
  import pytest
  import torch
  from gym import spaces
  from maze.perception.perception_utils import flatten_spaces, observation_spaces_to_in_shapes, map_nested_structure, convert_to_torch, convert_to_numpy, stack_and_flatten_spaces
label_desc: Use image node_id 5 for calling a global function with example usage: test_convert_to_torch() without return types