class_docstr: Batchify FasterRCNN data with 5 elements: img, bbox, rpn_cls_targets, rpn_box_targets,
  and rpn_box_masks
  Parameters
  ----------
  net : mxnet.gluon.HybridBlock.
      The faster-rcnn network used to infer output shape.
  num_shards : int, default 1
      Number of shards. Each shard corresponds to one device.
class_docstr_tok: ["Batchify","FasterRCNN","data","with","5","elements",":","img",",","bbox",",","rpn_cls_targets",",","rpn_box_targets",",","and","rpn_box_masks","Parameters","--","--","--","--","--","net",":","mxnet.gluon.HybridBlock",".","The","faster-rcnn","network","used","to","infer","output","shape",".","num_shards",":","int",",","default","1","Number","of","shards",".","Each","shard","corresponds","to","one","device","."]
docstr: Batchify the input data.
  Parameters
  ----------
  data : list
      The input data samples
  Returns
  -------
  batch_data : a tuple of NDArray
docstr_tok: ["Batchify","the","input","data",".","Parameters","--","--","--","--","--","data",":","list","The","input","data","samples","Returns","--","--","--","-","batch_data",":","a","tuple","of","NDArray"]
code: def __call__(self, data):
      """Batchify the input data.
      Parameters
      ----------
      data : list
          The input data samples
      Returns
      -------
      batch_data : a tuple of NDArray
      """
      assert len(data[0]) == self.NUM_ELEMENTS, (
          "The number of attributes in each data sample should contains"
          " {} elements, given {}.".format(
              self.NUM_ELEMENTS, len(data[0])
          )
      )
      data = tuple(zip(*data))
      sharded_img = self._img_pad(data[0])
      sharded_label = self._label_pad(data[1])
      # deal with rpn targets
      in_shapes = [
          img.shape if len(img.shape) == 2 else img.shape[1:]
          for shard in sharded_img
          for img in shard
      ]
      sharded_cls_targets, sharded_box_targets, sharded_box_masks = (
          [],
          [],
          [],
      )
      for in_shape, cls_targets, box_targets, box_masks in zip(
          in_shapes, *data[2:]
      ):
          padded_cls_targets, padded_box_targets, padded_box_masks = (
              [],
              [],
              [],
          )
          for feat_sym, cls_target, box_target, box_mask in zip(
              self._feat_sym, cls_targets, box_targets, box_masks
          ):
              _, _, w, h = feat_sym.infer_shape(
                  data=(1, 3, in_shape[0], in_shape[1])
              )[1][0]
              padded_cls_target = (
                  mx.nd.ones(shape=(w, h, cls_target.shape[-1])) * -1.0
              )
              padded_box_target = mx.nd.zeros(
                  shape=(w, h, box_target.shape[-1])
              )
              padded_box_mask = mx.nd.zeros(
                  shape=(w, h, box_mask.shape[-1])
              )
              padded_cls_target[
                  : cls_target.shape[0], : cls_target.shape[1]
              ] = cls_target
              padded_box_target[
                  : box_target.shape[0], : box_target.shape[1]
              ] = box_target
              padded_box_mask[
                  : box_mask.shape[0], : box_mask.shape[1]
              ] = box_mask
              padded_cls_targets.append(
                  padded_cls_target.reshape(1, -1)
              )
              padded_box_targets.append(
                  padded_box_target.reshape(1, -1, 4)
              )
              padded_box_masks.append(padded_box_mask.reshape(1, -1, 4))
          sharded_cls_targets.append(
              mx.nd.concat(*padded_cls_targets, dim=1)
          )
          sharded_box_targets.append(
              mx.nd.concat(*padded_box_targets, dim=1)
          )
          sharded_box_masks.append(
              mx.nd.concat(*padded_box_masks, dim=1)
          )
      shard_size = int(
          np.ceil(1.0 * len(sharded_cls_targets) / self._num_shards)
      )
      for i in range(self._num_shards):
          start_ind = int(i * shard_size)
          end_ind = int(start_ind + shard_size)
          (
              sharded_cls_targets[i],
              sharded_box_targets[i],
              sharded_box_masks[i],
          ) = (
              mx.nd.concat(
                  *sharded_cls_targets[start_ind:end_ind], dim=0
              ).as_in_context(mx.Context("cpu_shared", 0)),
              mx.nd.concat(
                  *sharded_box_targets[start_ind:end_ind], dim=0
              ).as_in_context(mx.Context("cpu_shared", 0)),
              mx.nd.concat(
                  *sharded_box_masks[start_ind:end_ind], dim=0
              ).as_in_context(mx.Context("cpu_shared", 0)),
          )
  
      return (
          sharded_img,
          sharded_label,
          tuple(sharded_cls_targets[: self._num_shards]),
          tuple(sharded_box_targets[: self._num_shards]),
          tuple(sharded_box_masks[: self._num_shards]),
      )
  
imports: import logging
  import numpy
  import mxnet
label_desc: Use image node_id 2 for calling the FasterRCNNTrainBatchify obj's underlying member method code with example usage: obj.__call__(data) and returns: sharded_img,  sharded_label,  tuple,  tuple,  tuple