docstr: Helper method to wrangle data into the format that the underlying model requires.
  
  :param data: Includes train and dev data datasources.
  :param output_dtype
  :return: modified `data` object that conforms to LightGBM's expected format.
docstr_tok: ["Helper","method","to","wrangle","data","into","the","format","that","the","underlying","model","requires",".",":","param","data",":","Includes","train","and","dev","data","datasources",".",":","param","output_dtype",":","return",":","modified","`","data","`","object","that","conforms","to","LightGBM","'s","expected","format","."]
code: def _to_dataset(self, data: Dict[str, Dict], output_dtype: str):
      """
      Helper method to wrangle data into the format that the underlying model requires.
  
      :param data: Includes train and dev data datasources.
      :param output_dtype
      :return: modified `data` object that conforms to LightGBM's expected format.
      """
      weight_map = getattr(self.target_encoder, "target_weights", None)
  
      for subset_name in data.keys():
          for input_col in self.input_cols:
              if data[subset_name]["data"] is None:
                  data[subset_name]["data"] = (
                      data[subset_name]["ds"]
                      .get_encoded_column_data(input_col)
                      .to(self.device)
                  )
              else:
                  enc_col = data[subset_name][
                      "ds"
                  ].get_encoded_column_data(input_col)
                  data[subset_name]["data"] = torch.cat(
                      (
                          data[subset_name]["data"],
                          enc_col.to(self.device),
                      ),
                      1,
                  )
  
          data[subset_name]["data"] = (
              data[subset_name]["data"].cpu().numpy()
          )
  
          label_data = data[subset_name]["ds"].get_column_original_data(
              self.target
          )
  
          data[subset_name]["weights"] = None
          if output_dtype in self.cls_dtypes:
              if subset_name == "train":
                  self.ordinal_encoder = OrdinalEncoder()
                  self.label_set = set(label_data)
                  self.label_set.add("__mdb_unknown_cat")
                  self.ordinal_encoder.fit(
                      np.array(list(self.label_set)).reshape(-1, 1)
                  )
  
              label_data = [
                  x if x in self.label_set else "__mdb_unknown_cat"
                  for x in label_data
              ]
              if weight_map is not None:
                  data[subset_name]["weights"] = [
                      weight_map[x] for x in label_data
                  ]
              label_data = self.ordinal_encoder.transform(
                  np.array(label_data).reshape(-1, 1)
              ).flatten()
          elif output_dtype == dtype.integer:
              label_data = label_data.clip(
                  -pow(2, 63), pow(2, 63)
              ).astype(int)
          elif output_dtype in self.float_dtypes:
              label_data = label_data.astype(float)
  
          data[subset_name]["label_data"] = label_data
  
      return data
  
imports: import time
  import inspect
  from typing import Dict, List, Set, Optional
  import torch
  import optuna
  import lightgbm
  import numpy
  import pandas
  from sklearn.preprocessing import OrdinalEncoder
  import optuna.integration.lightgbm
  from type_infer.dtype import dtype
  from lightwood.encoder.base import BaseEncoder
  from lightwood.helpers.log import log
  from lightwood.mixer.base import BaseMixer
  from lightwood.helpers.device import get_devices
  from lightwood.api.types import PredictionArguments
  from lightwood.data.encoded_ds import EncodedDs
label_desc: Use image node_id 2 for calling the LightGBM obj's underlying member method code with example usage: obj._to_dataset(data, output_dtype) and returns: data