class_docstr: A set of data which is used in the model optimization process. The FeatureSet can be accessed in
  a random data sample sequence. In the training process, the data sequence is a looped endless
  sequence. While in the validation process, the data sequence is a limited length sequence.
  Different from BigDL's DataSet, this FeatureSet could be cached to Intel Optane DC Persistent
  Memory, if you set memory_type to PMEM when creating FeatureSet.
class_docstr_tok: ["A","set","of","data","which","is","used","in","the","model","optimization","process",".","The","FeatureSet","can","be","accessed","in","a","random","data","sample","sequence",".","In","the","training","process",",","the","data","sequence","is","a","looped","endless","sequence",".","While","in","the","validation","process",",","the","data","sequence","is","a","limited","length","sequence",".","Different","from","BigDL","'s","DataSet",",","this","FeatureSet","could","be","cached","to","Intel","Optane","DC","Persistent","Memory",",","if","you","set","memory_type","to","PMEM","when","creating","FeatureSet","."]
docstr: Create FeatureSet from pytorch dataloader
  :param dataloader: a pytorch dataloader, or a function return pytorch dataloader.
  :param features: features in _data, _data is get from dataloader.
  :param labels: lables in _data, _data is get from dataloader.
  :param bigdl_type: numeric type
  :return: A feature set
docstr_tok: ["Create","FeatureSet","from","pytorch","dataloader",":","param","dataloader",":","a","pytorch","dataloader",",","or","a","function","return","pytorch","dataloader",".",":","param","features",":","features","in","_data",",","_data","is","get","from","dataloader",".",":","param","labels",":","lables","in","_data",",","_data","is","get","from","dataloader",".",":","param","bigdl_type",":","numeric","type",":","return",":","A","feature","set"]
code: def pytorch_dataloader(
      cls,
      dataloader,
      features="_data[0]",
      labels="_data[1]",
      bigdl_type="float",
  ):
      """
      Create FeatureSet from pytorch dataloader
      :param dataloader: a pytorch dataloader, or a function return pytorch dataloader.
      :param features: features in _data, _data is get from dataloader.
      :param labels: lables in _data, _data is get from dataloader.
      :param bigdl_type: numeric type
      :return: A feature set
      """
      import torch
  
      if isinstance(dataloader, torch.utils.data.DataLoader):
          node_num, core_num = get_node_and_core_number()
          if dataloader.batch_size % node_num != 0:
              true_bs = (
                  math.ceil(dataloader.batch_size / node_num) * node_num
              )
              warning_msg = (
                  "Detect dataloader's batch_size is not divisible by node number("
                  + str(node_num)
                  + "), will adjust batch_size to "
                  + str(true_bs)
                  + " automatically"
              )
              warnings.warn(warning_msg)
  
          bys = CloudPickleSerializer.dumps(
              CloudPickleSerializer, dataloader
          )
          jvalue = callZooFunc(
              bigdl_type,
              "createFeatureSetFromPyTorch",
              bys,
              False,
              features,
              labels,
          )
          return cls(jvalue=jvalue)
      elif callable(dataloader):
          bys = CloudPickleSerializer.dumps(
              CloudPickleSerializer, dataloader
          )
          jvalue = callZooFunc(
              bigdl_type,
              "createFeatureSetFromPyTorch",
              bys,
              True,
              features,
              labels,
          )
          return cls(jvalue=jvalue)
      else:
          raise ValueError(
              "Unsupported dataloader type, please pass pytorch dataloader"
              + " or a function to create pytorch dataloader."
          )
  
imports: from bigdl.util.common import *
  from zoo.common.utils import callZooFunc
  from bigdl.dataset.dataset import DataSet
  from pyspark.serializers import CloudPickleSerializer
  import sys
  import math
  import warnings
label_desc: Use image node_id 7 for calling the FeatureSet obj's underlying member method code with example usage: obj.pytorch_dataloader(cls, dataloader, features, labels, bigdl_type) and returns: cls, cls