code: def test_set_device_and_dtype():
      model = nn.Sequential(nn.Linear(8, 8), nn.ReLU(), nn.Linear(8, 4))
      batches = [torch.rand(8) for _ in range(2)]
      model, batches = set_device_and_dtype(
          model, batches, device="cpu", dtype=torch.float32
      )
      assert model[0].weight.device == torch.device("cpu")
      assert model[0].weight.dtype == torch.float32
      assert batches[0].device == torch.device("cpu")
      assert batches[0].dtype == torch.float32
      model, batches = set_device_and_dtype(
          model, batches, device="cpu", dtype=torch.float16
      )
      assert model[0].weight.dtype == torch.float16
      assert batches[0].dtype == torch.float16
  
file_path: doctr/tests/pytorch/test_models_utils_pt.py
imports: import os
  import pytest
  import torch
  from torch import nn
  from doctr.models.utils import _bf16_to_float32, _copy_tensor, conv_sequence_pt, load_pretrained_params, set_device_and_dtype
label_desc: Use image node_id 5 for calling a global function with example usage: test_set_device_and_dtype() without return types