code: def test_data_container_from_and_to_dict(
      img_3x4, mask_3x4, order, presence
  ):
      img, mask = img_3x4, mask_3x4
      kpts_data = (
          np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
          .reshape((4, 2))
          .astype(float)
      )
      dc, dc_reordered = generate_data_container_based_on_presence(
          img, mask, kpts_data, order, presence
      )
      assert dc == dc_reordered
  
      # Now we will also test whether conversion to dict and back works well.
      tensor_dict = dc_reordered.to_torch(
          as_dict=True, normalize=False, scale_keypoints=False
      )
      for k in tensor_dict:
          if isinstance(tensor_dict[k], (list, tuple)):
              tmp = []
              for el in tensor_dict[k]:
                  tmp.append(
                      el.numpy() if isinstance(el, torch.Tensor) else el
                  )
                  if "imag" in k:
                      tmp[-1] = (
                          tmp[-1].transpose((1, 2, 0)) * 255
                      ).astype(np.uint8)
                  if "mask" in k:
                      tmp[-1] = tmp[-1].astype(np.uint8).squeeze()
                  if "keypoints" in k:
                      tmp[-1] = slc.Keypoints(tmp[-1], 3, 4)
  
              tensor_dict[k] = tmp
          else:
              el = tensor_dict[k]
              tensor_dict[k] = (
                  (el.numpy()).astype(np.uint8)
                  if isinstance(el, torch.Tensor)
                  else el
              )
              if "imag" in k:
                  tensor_dict[k] = (
                      tensor_dict[k].transpose((1, 2, 0)) * 255
                  ).astype(np.uint8)
              if "mask" in k:
                  tensor_dict[k] = (
                      tensor_dict[k].astype(np.uint8).squeeze()
                  )
              if "keypoints" in k:
                  tensor_dict[k] = slc.Keypoints(tensor_dict[k], 3, 4)
  
      assert dc == slc.DataContainer.from_dict(tensor_dict)
  
imports: import itertools
  import random
  import cv2
  import numpy
  import pytest
  import torch
  import solt.core
  import solt.transforms
  import solt.utils
  from .fixtures import *
label_desc: Use image node_id 41 for calling a global function with example usage: test_data_container_from_and_to_dict(img_3x4, mask_3x4, order, presence) without return types