code: def test_dict(self):
      # simulate complicated input data
      test_data = {
          "img": np.array([1.0, 2.0], dtype=np.float32),
          "meta": {
              "dims": 3,
              "size": np.array([1, 2, 3]),
              "path": "temp/test",
          },
          "extra": None,
      }
      for dtype in ("tensor", "numpy"):
          trans = EnsureTyped(
              keys=["data", "label"],
              data_type=dtype,
              dtype=[np.float32, np.int8],
              device="cpu",
          )({"data": test_data, "label": test_data})
          for key in ("data", "label"):
              result = trans[key]
              self.assertTrue(isinstance(result, dict))
              self.assertTrue(
                  isinstance(
                      result["img"],
                      torch.Tensor if dtype == "tensor" else np.ndarray,
                  )
              )
              self.assertTrue(
                  isinstance(
                      result["meta"]["size"],
                      torch.Tensor if dtype == "tensor" else np.ndarray,
                  )
              )
              self.assertEqual(result["meta"]["path"], "temp/test")
              self.assertEqual(result["extra"], None)
              assert_allclose(
                  result["img"],
                  torch.as_tensor([1.0, 2.0]),
                  type_test=False,
              )
              assert_allclose(
                  result["meta"]["size"],
                  torch.as_tensor([1, 2, 3]),
                  type_test=False,
              )
          if dtype == "numpy":
              self.assertTrue(trans["data"]["img"].dtype == np.float32)
              self.assertTrue(trans["label"]["img"].dtype == np.int8)
          else:
              self.assertTrue(
                  trans["data"]["img"].dtype == torch.float32
              )
              self.assertTrue(trans["label"]["img"].dtype == torch.int8)
  
file_path: MONAI/tests/test_ensure_typed.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from monai.data import MetaTensor
  from monai.transforms import EnsureTyped
  from tests.utils import assert_allclose
label_desc: Use image node_id 5 for calling the TestEnsureTyped obj's underlying member method code with example usage: obj.test_dict() without return types