code: def convert_batched_inputs_to_c2_format(
      batched_inputs, size_divisibility, device
  ):
      """
      See get_caffe2_inputs() below.
      """
      assert all(isinstance(x, dict) for x in batched_inputs)
      assert all(x["image"].dim() == 3 for x in batched_inputs)
  
      images = [x["image"] for x in batched_inputs]
      images = ImageList.from_tensors(images, size_divisibility)
  
      im_info = []
      for input_per_image, image_size in zip(
          batched_inputs, images.image_sizes
      ):
          target_height = input_per_image.get("height", image_size[0])
          target_width = input_per_image.get(
              "width", image_size[1]
          )  # noqa
          # NOTE: The scale inside im_info is kept as convention and for providing
          # post-processing information if further processing is needed. For
          # current Caffe2 model definitions that don't include post-processing inside
          # the model, this number is not used.
          # NOTE: There can be a slight difference between width and height
          # scales, using a single number can results in numerical difference
          # compared with D2's post-processing.
          scale = target_height / image_size[0]
          im_info.append([image_size[0], image_size[1], scale])
      im_info = torch.Tensor(im_info)
  
      return images.tensor.to(device), im_info.to(device)
  
imports: import functools
  import io
  import struct
  import types
  import torch
  from detectron2.modeling import meta_arch
  from detectron2.modeling.box_regression import Box2BoxTransform
  from detectron2.modeling.roi_heads import keypoint_head
  from detectron2.structures import Boxes, ImageList, Instances, RotatedBoxes
  from .c10 import Caffe2Compatible
  from .caffe2_patch import ROIHeadsPatcher, patch_generalized_rcnn
  from .shared import alias, check_set_pb_arg, get_pb_arg_floats, get_pb_arg_valf, get_pb_arg_vali, get_pb_arg_vals, mock_torch_nn_functional_interpolate
label_desc: Use image node_id 4 for calling a global function with example usage: convert_batched_inputs_to_c2_format(batched_inputs, size_divisibility, device) and returns: images,  im_info