code: def test_from_to_meta_tensord(
      self, device, dtype, data_type="tensor"
  ):
      m1 = self.get_im(device=device, dtype=dtype)
      m2 = self.get_im(device=device, dtype=dtype)
      m3 = self.get_im(device=device, dtype=dtype)
      d_metas = {"m1": m1, "m2": m2, "m3": m3}
      m1_meta = {k: v for k, v in m1.meta.items() if k != "affine"}
      m1_aff = m1.affine
  
      # FROM -> forward
      t_from_meta = FromMetaTensord(["m1", "m2"], data_type=data_type)
      d_dict = t_from_meta(d_metas)
  
      self.assertEqual(
          sorted(d_dict.keys()),
          [
              "m1",
              PostFix.meta("m1"),
              PostFix.transforms("m1"),
              "m2",
              PostFix.meta("m2"),
              PostFix.transforms("m2"),
              "m3",
          ],
      )
      self.check(d_dict["m3"], m3, ids=True)  # unchanged
      if data_type == "tensor":
          self.check(d_dict["m1"], m1.as_tensor(), ids=False)
      else:
          self.assertIsInstance(d_dict["m1"], np.ndarray)
      meta_out = {
          k: v
          for k, v in d_dict["m1_meta_dict"].items()
          if k != "affine"
      }
      aff_out = d_dict["m1_meta_dict"]["affine"]
      self.check(aff_out, m1_aff, ids=False)
      self.assertEqual(meta_out, m1_meta)
  
      # FROM -> inverse
      d_meta_dict_meta = t_from_meta.inverse(d_dict)
      self.assertEqual(
          sorted(d_meta_dict_meta.keys()), ["m1", "m2", "m3"]
      )
      if data_type == "numpy":
          m1, m1_aff = m1.cpu(), m1_aff.cpu()
      self.check(d_meta_dict_meta["m1"], m1, ids=False)
      meta_out = {
          k: v
          for k, v in d_meta_dict_meta["m1"].meta.items()
          if k != "affine"
      }
      aff_out = d_meta_dict_meta["m1"].affine
      self.check(aff_out, m1_aff, ids=False)
      self.assertEqual(meta_out, m1_meta)
  
      # TO -> Forward
      t_to_meta = ToMetaTensord(["m1", "m2"])
      d_dict_meta = t_to_meta(d_dict)
      self.assertEqual(
          sorted(d_dict_meta.keys()),
          ["m1", "m2", "m3"],
          f"flag: {config.USE_META_DICT}",
      )
      self.check(
          d_dict_meta["m3"], m3, ids=True
      )  # unchanged (except deep copy in inverse)
      self.check(d_dict_meta["m1"], m1, ids=False)
      meta_out = {
          k: v
          for k, v in d_dict_meta["m1"].meta.items()
          if k != "affine"
      }
      aff_out = d_dict_meta["m1"].meta["affine"]
      self.check(aff_out, m1_aff, ids=False)
      self.assertEqual(meta_out, m1_meta)
  
      # TO -> Inverse
      d_dict_meta_dict = t_to_meta.inverse(d_dict_meta)
      self.assertEqual(
          sorted(d_dict_meta_dict.keys()),
          [
              "m1",
              PostFix.meta("m1"),
              PostFix.transforms("m1"),
              "m2",
              PostFix.meta("m2"),
              PostFix.transforms("m2"),
              "m3",
          ],
      )
      self.check(
          d_dict_meta_dict["m3"], m3.as_tensor(), ids=False
      )  # unchanged (except deep copy in inverse)
      self.check(d_dict_meta_dict["m1"], m1.as_tensor(), ids=False)
      meta_out = {
          k: v
          for k, v in d_dict_meta_dict["m1_meta_dict"].items()
          if k != "affine"
      }
      aff_out = d_dict_meta_dict["m1_meta_dict"]["affine"]
      self.check(aff_out, m1_aff, ids=False)
      self.assertEqual(meta_out, m1_meta)
  
imports: from __future__ import annotations
  import random
  import string
  import unittest
  from copy import deepcopy
  import numpy
  import torch
  from parameterized import parameterized
  from monai import config
  from monai.data.meta_tensor import MetaTensor
  from monai.transforms import FromMetaTensord, ToMetaTensord
  from monai.utils.enums import PostFix
  from tests.utils import TEST_DEVICES, assert_allclose
label_desc: Use image node_id 4 for calling the TestToFromMetaTensord obj's underlying member method code with example usage: obj.test_from_to_meta_tensord(device, dtype, data_type) without return types