code: def test_estimator_train_imagefeature(self):
      batch_size = 8
      epoch_num = 5
      images, labels = TestEstimator._generate_image_data(
          data_num=8, img_shape=(200, 200, 3)
      )
  
      image_frame = DistributedImageFrame(
          self.sc.parallelize(images), self.sc.parallelize(labels)
      )
  
      transformer = Pipeline(
          [
              BytesToMat(),
              Resize(256, 256),
              CenterCrop(224, 224),
              ChannelNormalize(
                  0.485, 0.456, 0.406, 0.229, 0.224, 0.225
              ),
              MatToTensor(),
              ImageFrameToSample(target_keys=["label"]),
          ]
      )
      data_set = FeatureSet.image_frame(image_frame).transform(
          transformer
      )
  
      model = TestEstimator._create_cnn_model()
  
      optim_method = SGD(learningrate=0.01)
  
      estimator = Estimator(model, optim_method, "")
      estimator.set_constant_gradient_clipping(0.1, 1.2)
      estimator.train_imagefeature(
          train_set=data_set,
          criterion=ClassNLLCriterion(),
          end_trigger=MaxEpoch(epoch_num),
          checkpoint_trigger=EveryEpoch(),
          validation_set=data_set,
          validation_method=[Top1Accuracy()],
          batch_size=batch_size,
      )
      eval_result = estimator.evaluate_imagefeature(
          validation_set=data_set, validation_method=[Top1Accuracy()]
      )
      assert isinstance(eval_result[0], EvaluatedResult)
      assert len(eval_result) == 1
      predict_result = model.predict_image(
          image_frame.transform(transformer)
      )
      assert (predict_result.get_predict().count(), 8)
  
file_path: BigDL/python/dllib/test/bigdl/estimator/test_estimator.py
imports: import pytest
  from pyspark.ml import Pipeline
  from bigdl.dllib.estimator import *
  from bigdl.dllib.nn.layer import Sequential, View, Linear, LogSoftMax, SpatialConvolution
  from bigdl.dllib.nn.criterion import ClassNLLCriterion
  from bigdl.dllib.optim.optimizer import *
  from bigdl.dllib.utils.common import EvaluatedResult
  from test.bigdl.test_zoo_utils import ZooTestCase
  from bigdl.dllib.feature.common import FeatureSet
  from bigdl.dllib.nncontext import init_nncontext, init_spark_conf, ZooContext
  from bigdl.dllib.utils.file_utils import Sample
label_desc: Use image node_id 5 for calling the TestEstimator obj's underlying member method code with example usage: obj.test_estimator_train_imagefeature() without return types