code: def generate_data_container_based_on_presence(
      img, mask, kpts_data, order, presence
  ):
      kpts = slc.Keypoints(kpts_data.copy(), 3, 4)
  
      (
          n_obj1,
          n_obj2,
          n_obj3,
          n_obj4,
          n_obj5,
          n_obj6,
          n_obj7,
          n_obj8,
      ) = presence
      dc_content = []
      dc_format = ""
      order = list(order)
      d = {}
  
      if n_obj1:
          d["image"] = img
          dc_content.append(img)
          dc_format += "I"
      else:
          del order[order.index("image")]
      if n_obj2:
          d["images"] = [img.copy() for _ in range(n_obj2)]
          dc_content.extend(d["images"])
          dc_format += "I" * n_obj2
      else:
          del order[order.index("images")]
      if n_obj3:
          d["mask"] = mask
          dc_content.append(mask)
          dc_format += "M"
      else:
          del order[order.index("mask")]
      if n_obj4:
          d["masks"] = [mask.copy() for i in range(n_obj4)]
          dc_content.extend(d["masks"])
          dc_format += "M" * n_obj4
      else:
          del order[order.index("masks")]
      if n_obj5:
          d["keypoints"] = slc.Keypoints(kpts_data.copy(), 3, 4)
          dc_content.append(kpts)
          dc_format += "P"
      else:
          del order[order.index("keypoints")]
      if n_obj6:
          d["keypoints_array"] = [
              slc.Keypoints(kpts_data.copy(), 3, 4)
              for _ in range(n_obj6)
          ]
          dc_content.extend(d["keypoints_array"])
          dc_format += "P" * n_obj6
      else:
          del order[order.index("keypoints_array")]
      if n_obj7:
          d["label"] = 1
          dc_content.append(1)
          dc_format += "L"
      else:
          del order[order.index("label")]
      if n_obj8:
          d["labels"] = [1 for _ in range(n_obj8)]
          dc_content.extend([1 for _ in range(n_obj8)])
          dc_format += "L" * n_obj8
      else:
          del order[order.index("labels")]
      dc = slc.DataContainer(tuple(dc_content), dc_format)
  
      reordered_d = {k: d[k] for k in order}
  
      # This tests whether the creation from dict works as expected
      dc_reordered = slc.DataContainer.from_dict(reordered_d)
  
      return dc, dc_reordered
  
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 2 for calling a global function with example usage: generate_data_container_based_on_presence(img, mask, kpts_data, order, presence) and returns: dc,  dc_reordered