code: def setup_detection_train_tuning_data(
      self, max_num_tuning_data, seed, train_data, tuning_data
  ):
      if isinstance(train_data, str):
          self._detection_anno_train = train_data
          train_data = from_coco_or_voc(
              train_data, "train"
          )  # TODO: Refactor to use convert_data_to_df
          if tuning_data is not None:
              self.detection_anno_train = tuning_data
              tuning_data = from_coco_or_voc(
                  tuning_data, "val"
              )  # TODO: Refactor to use convert_data_to_df
              if max_num_tuning_data is not None:
                  if len(tuning_data) > max_num_tuning_data:
                      tuning_data = tuning_data.sample(
                          n=max_num_tuning_data,
                          replace=False,
                          random_state=seed,
                      ).reset_index(drop=True)
      elif isinstance(train_data, pd.DataFrame):
          self._detection_anno_train = None
          # sanity check dataframe columns
          train_data = object_detection_data_to_df(train_data)
          if tuning_data is not None:
              self.detection_anno_train = tuning_data
              tuning_data = object_detection_data_to_df(tuning_data)
              if max_num_tuning_data is not None:
                  if len(tuning_data) > max_num_tuning_data:
                      tuning_data = tuning_data.sample(
                          n=max_num_tuning_data,
                          replace=False,
                          random_state=seed,
                      ).reset_index(drop=True)
      else:
          raise TypeError(
              f"Expected train_data to have type str or pd.DataFrame, but got type: {type(train_data)}"
          )
      return train_data, tuning_data
  
imports: import json
  import logging
  import os
  from datetime import timedelta
  from typing import Dict, List, Optional, Union
  import pandas
  from omegaconf import DictConfig, OmegaConf
  from torch import nn
  from ..constants import BBOX, DDP, MAP, MULTI_IMAGE_MIX_DATASET, OBJECT_DETECTION, OPEN_VOCABULARY_OBJECT_DETECTION, OVD_RET, XYWH
  from ..data import BaseDataModule, MultiImageMixDataset, MultiModalFeaturePreprocessor, infer_rois_column_type
  from ..optimization import LitModule, MMDetLitModule
  from ..utils import check_if_packages_installed, cocoeval, convert_pred_to_xywh, create_fusion_model, extract_from_output, from_coco_or_voc, get_detection_classes, object_detection_data_to_df, save_ovd_result_df, save_result_df, setup_save_path, split_train_tuning_data
  from .base import BaseLearner
label_desc: Use image node_id 3 for calling the ObjectDetectionLearner obj's underlying member method code with example usage: obj.setup_detection_train_tuning_data(max_num_tuning_data, seed, train_data, tuning_data) and returns: train_data,  tuning_data