docstr: Train this BigDL model with train data.
  
  :param data: train data. It can be XShards or Spark DataFrame.
         If data is XShards, each partition is a dictionary of  {'x': feature,
         'y': label}, where feature(label) is a numpy array or a list of numpy arrays.
  :param epochs: Number of epochs to train the model.
  :param batch_size: Batch size used for training. Default: 32.
  :param feature_cols: Feature column name(s) of data. Only used when data is a Spark
         DataFrame. Default: "features".
  :param label_cols: Label column name(s) of data. Only used when data is a Spark DataFrame.
         Default: "label".
  :param caching_sample: whether to cache the Samples after preprocessing. Default: True
  :param validation_data: Validation data. XShards and Spark DataFrame are supported.
         If data is XShards, each partition is a dictionary of  {'x': feature,
         'y': label}, where feature(label) is a numpy array or a list of numpy arrays.
  :param validation_trigger: Orca Trigger to trigger validation computation.
  :param checkpoint_trigger: Orca Trigger to set a checkpoint.
  :return:
docstr_tok: ["Train","this","BigDL","model","with","train","data",".",":","param","data",":","train","data",".","It","can","be","XShards","or","Spark","DataFrame",".","If","data","is","XShards",",","each","partition","is","a","dictionary","of","{","'","x","'",":","feature",",","'","y","'",":","label","}",",","where","feature","(","label",")","is","a","numpy","array","or","a","list","of","numpy","arrays",".",":","param","epochs",":","Number","of","epochs","to","train","the","model",".",":","param","batch_size",":","Batch","size","used","for","training",".","Default",":","32.",":","param","feature_cols",":","Feature","column","name","(","s",")","of","data",".","Only","used","when","data","is","a","Spark","DataFrame",".","Default",":","``","features","''",".",":","param","label_cols",":","Label","column","name","(","s",")","of","data",".","Only","used","when","data","is","a","Spark","DataFrame",".","Default",":","``","label","''",".",":","param","caching_sample",":","whether","to","cache","the","Samples","after","preprocessing",".","Default",":","True",":","param","validation_data",":","Validation","data",".","XShards","and","Spark","DataFrame","are","supported",".","If","data","is","XShards",",","each","partition","is","a","dictionary","of","{","'","x","'",":","feature",",","'","y","'",":","label","}",",","where","feature","(","label",")","is","a","numpy","array","or","a","list","of","numpy","arrays",".",":","param","validation_trigger",":","Orca","Trigger","to","trigger","validation","computation",".",":","param","checkpoint_trigger",":","Orca","Trigger","to","set","a","checkpoint",".",":","return",":"]
code: def fit(
      self,
      data,
      epochs,
      batch_size=32,
      feature_cols="features",
      label_cols="label",
      caching_sample=True,
      validation_data=None,
      validation_trigger=None,
      checkpoint_trigger=None,
  ):
      """
      Train this BigDL model with train data.
  
      :param data: train data. It can be XShards or Spark DataFrame.
             If data is XShards, each partition is a dictionary of  {'x': feature,
             'y': label}, where feature(label) is a numpy array or a list of numpy arrays.
      :param epochs: Number of epochs to train the model.
      :param batch_size: Batch size used for training. Default: 32.
      :param feature_cols: Feature column name(s) of data. Only used when data is a Spark
             DataFrame. Default: "features".
      :param label_cols: Label column name(s) of data. Only used when data is a Spark DataFrame.
             Default: "label".
      :param caching_sample: whether to cache the Samples after preprocessing. Default: True
      :param validation_data: Validation data. XShards and Spark DataFrame are supported.
             If data is XShards, each partition is a dictionary of  {'x': feature,
             'y': label}, where feature(label) is a numpy array or a list of numpy arrays.
      :param validation_trigger: Orca Trigger to trigger validation computation.
      :param checkpoint_trigger: Orca Trigger to set a checkpoint.
      :return:
      """
      from zoo.orca.learn.trigger import Trigger
  
      assert batch_size > 0, "batch_size should be greater than 0"
  
      if validation_data is not None:
          assert self.metrics is not None, (
              "You should provide metrics when creating this estimator if you provide "
              "validation_data."
          )
  
      if isinstance(data, DataFrame):
          if isinstance(feature_cols, list):
              (
                  data,
                  validation_data,
                  feature_cols,
              ) = BigDLEstimator._combine_cols(
                  data,
                  feature_cols,
                  col_name="features",
                  val_data=validation_data,
              )
  
          if isinstance(label_cols, list):
              (
                  data,
                  validation_data,
                  label_cols,
              ) = BigDLEstimator._combine_cols(
                  data,
                  label_cols,
                  col_name="label",
                  val_data=validation_data,
              )
  
          self.nn_estimator.setBatchSize(batch_size).setMaxEpoch(
              epochs
          ).setCachingSample(caching_sample).setFeaturesCol(
              feature_cols
          ).setLabelCol(
              label_cols
          )
  
          if validation_data is not None:
              assert isinstance(
                  validation_data, DataFrame
              ), "validation_data should be a spark DataFrame."
              assert (
                  validation_trigger is not None
              ), "You should provide validation_trigger if you provide validation_data."
              validation_trigger = Trigger.convert_trigger(
                  validation_trigger
              )
              self.nn_estimator.setValidation(
                  validation_trigger,
                  validation_data,
                  self.metrics,
                  batch_size,
              )
          if self.log_dir is not None and self.app_name is not None:
              from bigdl.optim.optimizer import TrainSummary
              from bigdl.optim.optimizer import ValidationSummary
  
              train_summary = TrainSummary(
                  log_dir=self.log_dir, app_name=self.app_name
              )
              self.nn_estimator.setTrainSummary(train_summary)
              val_summary = ValidationSummary(
                  log_dir=self.log_dir, app_name=self.app_name
              )
              self.nn_estimator.setValidationSummary(val_summary)
          if (
              self.model_dir is not None
              and checkpoint_trigger is not None
          ):
              checkpoint_trigger = Trigger.convert_trigger(
                  checkpoint_trigger
              )
              self.nn_estimator.setCheckpoint(
                  self.model_dir, checkpoint_trigger
              )
  
          self.nn_model = self.nn_estimator.fit(data)
          self.is_nnframe_fit = True
      elif isinstance(data, SparkXShards):
          from zoo.orca.data.utils import xshard_to_sample
  
          end_trigger = MaxEpoch(epochs)
          checkpoint_trigger = Trigger.convert_trigger(
              checkpoint_trigger
          )
  
          if isinstance(data, SparkXShards):
              train_rdd = data.rdd.flatMap(xshard_to_sample)
              train_feature_set = FeatureSet.sample_rdd(train_rdd)
              if validation_data is None:
                  val_feature_set = None
              else:
                  assert isinstance(
                      validation_data, SparkXShards
                  ), "validation_data should be a XShards"
                  val_feature_set = FeatureSet.sample_rdd(
                      validation_data.rdd.flatMap(xshard_to_sample)
                  )
              if self.log_dir is not None and self.app_name is not None:
                  self.estimator.set_tensorboard(
                      self.log_dir, self.app_name
                  )
              self.estimator.train(
                  train_feature_set,
                  self.loss,
                  end_trigger,
                  checkpoint_trigger,
                  val_feature_set,
                  self.metrics,
                  batch_size,
              )
              self.is_nnframe_fit = False
          else:
              raise ValueError(
                  "Data and validation data should be XShards, but get "
                  + data.__class__.__name__
              )
      else:
          raise ValueError(
              "Data should be XShards or Spark DataFrame, but get "
              + data.__class__.__name__
          )
      return self
  
imports: from zoo.orca.learn.metrics import Metric
  from zoo.orca.learn.utils import bigdl_metric_results_to_dict
  from zoo.pipeline.nnframes import NNEstimator, NNModel
  from zoo.pipeline.estimator import Estimator
  from zoo.orca.learn.spark_estimator import Estimator
  from zoo.orca.data import SparkXShards
  from bigdl.optim.optimizer import MaxEpoch
  from zoo.feature.common import FeatureSet
  from zoo.orca.learn.metrics import Accuracy
  from pyspark.sql.dataframe import DataFrame
label_desc: Use image node_id 2 for calling the BigDLEstimator obj's underlying member method code with example usage: obj.fit(data, epochs, batch_size, feature_cols, label_cols, caching_sample, validation_data, validation_trigger, checkpoint_trigger) and returns: self