code: def add_data(
      self, config: _MixedDatasetConfig
  ) -> Optional[CPMBeeBatch]:
      (
          input_ids,
          input_id_subs,
          context,
          segment_ids,
          segment_rel_offset,
          segment_rel,
          sample_ids,
          num_segments,
          raw_data,
      ) = self.build_instance(config)
  
      # add to batch
      best_fit: Union[None, int] = None
      best_fit_space: Union[None, int] = None
      for i in range(len(self._inputs)):
          space = self._max_length - self._inputs[i].shape[0]
          if input_ids.shape[0] <= space:
              if best_fit_space is None:
                  best_fit = i
                  best_fit_space = space
              elif best_fit_space > space:
                  best_fit = i
                  best_fit_space = space
      if best_fit is None:
          # add a new instance
          self._inputs.append(input_ids)
          self._inputs_sub.append(input_id_subs)
          self._context.append(context)
          self._sample_ids.append(sample_ids)
          self._segments.append(segment_ids)
          self._num_segments.append(num_segments)
          self._segment_rel_offset.append(segment_rel_offset)
          self._segment_rel.append(segment_rel)
          self._spans.append([input_ids.shape[0]])
          self._task_ids.append([config["task_name"]])
          self._raw_data.append([raw_data])
      else:
          # add to existing instance
          self._inputs[best_fit] = np.concatenate(
              [self._inputs[best_fit], input_ids], axis=0
          )
          self._inputs_sub[best_fit] = np.concatenate(
              [self._inputs_sub[best_fit], input_id_subs], axis=0
          )
          self._context[best_fit] = np.concatenate(
              [self._context[best_fit], context], axis=0
          )
          self._sample_ids[best_fit] = np.concatenate(
              [self._sample_ids[best_fit], sample_ids], axis=0
          )
          self._segments[best_fit] = np.concatenate(
              [self._segments[best_fit], segment_ids], axis=0
          )
          self._num_segments[best_fit] = np.concatenate(
              [self._num_segments[best_fit], num_segments], axis=0
          )
          self._segment_rel_offset[best_fit] = np.concatenate(
              [
                  self._segment_rel_offset[best_fit],
                  segment_rel_offset
                  + self._segment_rel[best_fit].shape[0],
              ],
              axis=0,
          )
          self._segment_rel[best_fit] = np.concatenate(
              [self._segment_rel[best_fit], segment_rel], axis=0
          )
          self._spans[best_fit].append(self._inputs[best_fit].shape[0])
          self._task_ids[best_fit].append(config["task_name"])
          self._raw_data[best_fit].append(raw_data)
  
      if len(self._inputs) > self._batch_size:
          return self.pack_batch()
      else:
          # not ready
          return None
  
imports: from collections import OrderedDict
  import multiprocessing
  import os
  from queue import Empty
  from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
  from typing_extensions import TypedDict
  from ...dataset import DistributedDataset
  from ...tokenizers import CPMBeeTokenizer
  from ...utils.config import load_dataset_config
  import numpy
  import time
  from numpy.typing import NDArray
  import torch
  import bmtrain
  import importlib.machinery
  import importlib.util
  import types
  import random
label_desc: Use image node_id 8 for calling the _MixedDatasetBatchPacker obj's underlying member method code with example usage: obj.add_data(config) and returns: self, None