docstr: Train this torch model with train data.
  
  :param data: train data. It can be a XShards, Spark Dataframe, PyTorch DataLoader and
         PyTorch DataLoader creator function that takes config and batch_size as argument and
         returns a PyTorch DataLoader for training.
         If data is an XShards, each partition can be a Pandas DataFrame or 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. Default: 1.
  :param batch_size: Batch size used for training. Only used when data is an XShards.
         Default: 32.
  :param feature_cols: Feature column name(s) of data. Only used when data
         is a Spark DataFrame or an XShards of Pandas DataFrame. Default: None.
  :param label_cols: Label column name(s) of data. Only used when data is
         a Spark DataFrame or an XShards of Pandas DataFrame. Default: None.
  :param validation_data: Validation data. XShards, PyTorch DataLoader and PyTorch DataLoader
         creator function are supported.
         If data is XShards, each partition can be a Pandas DataFrame or a dictionary of
         {'x': feature, 'y': label}, where feature(label) is a numpy array or a list of
         numpy arrays.
  :param checkpoint_trigger: Orca Trigger to set a checkpoint.
  :return: The trained estimator object.
docstr_tok: ["Train","this","torch","model","with","train","data",".",":","param","data",":","train","data",".","It","can","be","a","XShards",",","Spark","Dataframe",",","PyTorch","DataLoader","and","PyTorch","DataLoader","creator","function","that","takes","config","and","batch_size","as","argument","and","returns","a","PyTorch","DataLoader","for","training",".","If","data","is","an","XShards",",","each","partition","can","be","a","Pandas","DataFrame","or","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",".","Default",":","1.",":","param","batch_size",":","Batch","size","used","for","training",".","Only","used","when","data","is","an","XShards",".","Default",":","32.",":","param","feature_cols",":","Feature","column","name","(","s",")","of","data",".","Only","used","when","data","is","a","Spark","DataFrame","or","an","XShards","of","Pandas","DataFrame",".","Default",":","None",".",":","param","label_cols",":","Label","column","name","(","s",")","of","data",".","Only","used","when","data","is","a","Spark","DataFrame","or","an","XShards","of","Pandas","DataFrame",".","Default",":","None",".",":","param","validation_data",":","Validation","data",".","XShards",",","PyTorch","DataLoader","and","PyTorch","DataLoader","creator","function","are","supported",".","If","data","is","XShards",",","each","partition","can","be","a","Pandas","DataFrame","or","a","dictionary","of","{","'","x","'",":","feature",",","'","y","'",":","label","}",",","where","feature","(","label",")","is","a","numpy","array","or","a","list","of","numpy","arrays",".",":","param","checkpoint_trigger",":","Orca","Trigger","to","set","a","checkpoint",".",":","return",":","The","trained","estimator","object","."]
code: def fit(
      self,
      data,
      epochs=1,
      batch_size=None,
      feature_cols=None,
      label_cols=None,
      validation_data=None,
      checkpoint_trigger=None,
  ):
      """
      Train this torch model with train data.
  
      :param data: train data. It can be a XShards, Spark Dataframe, PyTorch DataLoader and
             PyTorch DataLoader creator function that takes config and batch_size as argument and
             returns a PyTorch DataLoader for training.
             If data is an XShards, each partition can be a Pandas DataFrame or 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. Default: 1.
      :param batch_size: Batch size used for training. Only used when data is an XShards.
             Default: 32.
      :param feature_cols: Feature column name(s) of data. Only used when data
             is a Spark DataFrame or an XShards of Pandas DataFrame. Default: None.
      :param label_cols: Label column name(s) of data. Only used when data is
             a Spark DataFrame or an XShards of Pandas DataFrame. Default: None.
      :param validation_data: Validation data. XShards, PyTorch DataLoader and PyTorch DataLoader
             creator function are supported.
             If data is XShards, each partition can be a Pandas DataFrame or a dictionary of
             {'x': feature, 'y': label}, where feature(label) is a numpy array or a list of
             numpy arrays.
      :param checkpoint_trigger: Orca Trigger to set a checkpoint.
      :return: The trained estimator object.
      """
      from zoo.orca.learn.trigger import Trigger
  
      end_trigger = MaxEpoch(epochs)
      if isinstance(data, DataLoader):
          assert batch_size is None and data.batch_size > 0, (
              "When using PyTorch Dataloader as "
              "input, you need to specify the "
              "batch size in DataLoader and "
              "don't specify batch_size "
              "in the fit method."
          )
      else:
          assert (
              batch_size is not None and batch_size > 0
          ), "batch_size should be greater than 0"
      checkpoint_trigger = Trigger.convert_trigger(checkpoint_trigger)
  
      if self.log_dir is not None and self.app_name is not None:
          self.estimator.set_tensorboard(self.log_dir, self.app_name)
  
      if validation_data:
          assert self.metrics is not None, (
              "You should provide metrics when creating this "
              "estimator if you provide validation_data."
          )
  
      if isinstance(data, SparkXShards):
          if data._get_class_name() == "pandas.core.frame.DataFrame":
              (
                  data,
                  validation_data,
              ) = process_xshards_of_pandas_dataframe(
                  data,
                  feature_cols,
                  label_cols,
                  validation_data,
                  mode="fit",
              )
          train_fset, val_fset = self._handle_xshards(
              data, validation_data
          )
          self.estimator.train(
              train_fset,
              self.loss,
              end_trigger,
              checkpoint_trigger,
              val_fset,
              self.metrics,
              batch_size,
          )
      elif isinstance(data, DataFrame):
          train_fset, val_fset = self._handle_dataframe(
              data, validation_data, feature_cols, label_cols
          )
          self.estimator.train(
              train_fset,
              self.loss,
              end_trigger,
              checkpoint_trigger,
              val_fset,
              self.metrics,
              batch_size,
          )
      elif (
          isinstance(data, DataLoader)
          or callable(data)
          or isinstance(data, types.FunctionType)
      ):
          if isinstance(data, types.FunctionType):
              data, validation_data = data(
                  self.config, batch_size
              ), validation_data(self.config, batch_size)
          train_fset, val_fset = self._handle_data_loader(
              data, validation_data
          )
          self.estimator.train_minibatch(
              train_fset,
              self.loss,
              end_trigger,
              checkpoint_trigger,
              val_fset,
              self.metrics,
          )
      else:
          raise ValueError(
              "Data and validation data should be SparkXShards, DataLoaders or "
              "callable data_creators but get "
              + data.__class__.__name__
          )
  
      return self
  
imports: from zoo.common.utils import enable_multi_fs_load, enable_multi_fs_save
  from zoo.orca.data.utils import row_to_sample, xshard_to_sample
  from zoo.orca.learn.utils import convert_predict_rdd_to_dataframe, bigdl_metric_results_to_dict, process_xshards_of_pandas_dataframe
  from zoo.pipeline.estimator.estimator import Estimator
  from zoo.orca.learn.ray_estimator import Estimator
  from zoo.orca.learn.pytorch.training_operator import TrainingOperator
  from zoo.orca.learn.spark_estimator import Estimator
  from zoo.orca.learn.optimizers import Optimizer, SGD
  from zoo.orca.learn.metrics import Accuracy
  from zoo.orca.data import SparkXShards
  from bigdl.optim.optimizer import MaxEpoch, OptimMethod
  from zoo.feature.common import FeatureSet
  from torch.optim.optimizer import Optimizer
  from torch.utils.data import DataLoader
  from pyspark.sql import DataFrame
  import warnings
  import torch
  import types
label_desc: Use image node_id 5 for calling the PyTorchSparkEstimator obj's underlying member method code with example usage: obj.fit(data, epochs, batch_size, feature_cols, label_cols, validation_data, checkpoint_trigger) and returns: self