code: def test_to_dict(self):
      sample_list = test_utils.build_random_sample_list()
      sample_dict = sample_list.to_dict()
      self.assertTrue(isinstance(sample_dict, dict))
      # hasattr won't work anymore
      self.assertFalse(hasattr(sample_dict, "x"))
      keys_to_assert = ["x", "y", "z", "z.x", "z.y"]
  
      all_keys = True
      for key in keys_to_assert:
          current = sample_dict
          if "." in key:
              sub_keys = key.split(".")
              for sub_key in sub_keys:
                  all_keys = all_keys and sub_key in current
                  current = current[sub_key]
          else:
              all_keys = all_keys and key in current
  
      self.assertTrue(all_keys)
      self.assertTrue(isinstance(sample_dict, dict))
  
file_path: mmf/tests/common/test_sample.py
imports: import unittest
  import tests.test_utils
  import torch
  from mmf.common.sample import convert_batch_to_sample_list, Sample, SampleList, to_device
label_desc: Use image node_id 2 for calling the TestSampleList obj's underlying member method code with example usage: obj.test_to_dict() without return types