docstr: Trains a PyTorch model given training data for several epochs.
  Calls `TrainingOperator.train_epoch()` on N parallel workers simultaneously
  underneath the hood.
  
  :param data: An instance of SparkXShards, a Spark DataFrame or a function that
         takes config and batch_size as argument and returns a PyTorch DataLoader for
         training.
  :param epochs: The number of epochs to train the model. Default is 1.
  :param batch_size: The number of samples per batch for each worker. Default is 32.
         The total batch size would be workers_per_node*num_nodes.
         If your training data is a function, you can set batch_size to be the input
         batch_size of the function for the PyTorch DataLoader.
  :param profile: Boolean. Whether to return time stats for the training procedure.
         Default is False.
  :param reduce_results: Boolean. Whether to average all metrics across all workers into
         one dict. If a metric is a non-numerical value (or nested dictionaries), one value
         will be randomly selected among the workers. If False, returns a list of dicts for
         all workers.
         Default is True.
  :param info: An optional dictionary that can be passed to the TrainingOperator for
         train_epoch and train_batch.
  :param feature_cols: feature column names if data is Spark DataFrame.
  :param label_cols: label column names if data is Spark DataFrame.
  
  :return: A list of dictionary of metrics for every training epoch. If reduce_results is
          False, this will return a nested list of metric dictionaries whose length will be
          equal to the total number of workers.
          You can also provide custom metrics by passing in a custom training_operator_cls
          when creating the Estimator.
docstr_tok: ["Trains","a","PyTorch","model","given","training","data","for","several","epochs",".","Calls","`","TrainingOperator.train_epoch","(",")","`","on","N","parallel","workers","simultaneously","underneath","the","hood",".",":","param","data",":","An","instance","of","SparkXShards",",","a","Spark","DataFrame","or","a","function","that","takes","config","and","batch_size","as","argument","and","returns","a","PyTorch","DataLoader","for","training",".",":","param","epochs",":","The","number","of","epochs","to","train","the","model",".","Default","is","1.",":","param","batch_size",":","The","number","of","samples","per","batch","for","each","worker",".","Default","is","32",".","The","total","batch","size","would","be","workers_per_node","*","num_nodes",".","If","your","training","data","is","a","function",",","you","can","set","batch_size","to","be","the","input","batch_size","of","the","function","for","the","PyTorch","DataLoader",".",":","param","profile",":","Boolean",".","Whether","to","return","time","stats","for","the","training","procedure",".","Default","is","False",".",":","param","reduce_results",":","Boolean",".","Whether","to","average","all","metrics","across","all","workers","into","one","dict",".","If","a","metric","is","a","non-numerical","value","(","or","nested","dictionaries",")",",","one","value","will","be","randomly","selected","among","the","workers",".","If","False",",","returns","a","list","of","dicts","for","all","workers",".","Default","is","True",".",":","param","info",":","An","optional","dictionary","that","can","be","passed","to","the","TrainingOperator","for","train_epoch","and","train_batch",".",":","param","feature_cols",":","feature","column","names","if","data","is","Spark","DataFrame",".",":","param","label_cols",":","label","column","names","if","data","is","Spark","DataFrame",".",":","return",":","A","list","of","dictionary","of","metrics","for","every","training","epoch",".","If","reduce_results","is","False",",","this","will","return","a","nested","list","of","metric","dictionaries","whose","length","will","be","equal","to","the","total","number","of","workers",".","You","can","also","provide","custom","metrics","by","passing","in","a","custom","training_operator_cls","when","creating","the","Estimator","."]
code: def fit(
      self,
      data,
      epochs=1,
      batch_size=32,
      profile=False,
      reduce_results=True,
      info=None,
      feature_cols=None,
      label_cols=None,
  ):
      """
      Trains a PyTorch model given training data for several epochs.
      Calls `TrainingOperator.train_epoch()` on N parallel workers simultaneously
      underneath the hood.
  
      :param data: An instance of SparkXShards, a Spark DataFrame or a function that
             takes config and batch_size as argument and returns a PyTorch DataLoader for
             training.
      :param epochs: The number of epochs to train the model. Default is 1.
      :param batch_size: The number of samples per batch for each worker. Default is 32.
             The total batch size would be workers_per_node*num_nodes.
             If your training data is a function, you can set batch_size to be the input
             batch_size of the function for the PyTorch DataLoader.
      :param profile: Boolean. Whether to return time stats for the training procedure.
             Default is False.
      :param reduce_results: Boolean. Whether to average all metrics across all workers into
             one dict. If a metric is a non-numerical value (or nested dictionaries), one value
             will be randomly selected among the workers. If False, returns a list of dicts for
             all workers.
             Default is True.
      :param info: An optional dictionary that can be passed to the TrainingOperator for
             train_epoch and train_batch.
      :param feature_cols: feature column names if data is Spark DataFrame.
      :param label_cols: label column names if data is Spark DataFrame.
  
      :return: A list of dictionary of metrics for every training epoch. If reduce_results is
              False, this will return a nested list of metric dictionaries whose length will be
              equal to the total number of workers.
              You can also provide custom metrics by passing in a custom training_operator_cls
              when creating the Estimator.
      """
      return self.estimator.train(
          data=data,
          epochs=epochs,
          batch_size=batch_size,
          profile=profile,
          reduce_results=reduce_results,
          info=info,
          feature_cols=feature_cols,
          label_cols=label_cols,
      )
  
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 2 for calling the PyTorchRayEstimator obj's underlying member method code with example usage: obj.fit(data, epochs, batch_size, profile, reduce_results, info, feature_cols, label_cols) and returns: self