code: def main():
      _URL = "https://storage.googleapis.com/mledu-datasets/cats_and_dogs_filtered.zip"
      path_to_zip = tf.keras.utils.get_file(
          "cats_and_dogs.zip", origin=_URL, extract=True
      )
      PATH = os.path.join(
          os.path.dirname(path_to_zip), "cats_and_dogs_filtered"
      )
  
      train_dir = os.path.join(PATH, "train")
      validation_dir = os.path.join(PATH, "validation")
  
      BATCH_SIZE = 32
      IMG_SIZE = (160, 160)
  
      train_dataset = image_dataset_from_directory(
          train_dir,
          shuffle=True,
          batch_size=BATCH_SIZE,
          image_size=IMG_SIZE,
      )
  
      validation_dataset = image_dataset_from_directory(
          validation_dir,
          shuffle=True,
          batch_size=BATCH_SIZE,
          image_size=IMG_SIZE,
      )
  
      val_batches = tf.data.experimental.cardinality(validation_dataset)
      test_dataset = validation_dataset.take(val_batches // 5)
      validation_dataset = validation_dataset.skip(val_batches // 5)
  
      print(
          "Number of validation batches: %d"
          % tf.data.experimental.cardinality(validation_dataset)
      )
      print(
          "Number of test batches: %d"
          % tf.data.experimental.cardinality(test_dataset)
      )
  
      AUTOTUNE = tf.data.AUTOTUNE
  
      train_dataset = train_dataset.prefetch(buffer_size=AUTOTUNE)
      validation_dataset = validation_dataset.prefetch(
          buffer_size=AUTOTUNE
      )
      test_dataset = test_dataset.prefetch(buffer_size=AUTOTUNE)
  
      data_augmentation = Sequential(
          [
              tf.keras.layers.experimental.preprocessing.RandomFlip(
                  "horizontal"
              ),
              tf.keras.layers.experimental.preprocessing.RandomRotation(
                  0.2
              ),
          ]
      )
  
      preprocess_input = (
          tf.keras.applications.mobilenet_v2.preprocess_input
      )
  
      rescale = tf.keras.layers.experimental.preprocessing.Rescaling(
          1.0 / 127.5, offset=-1
      )
  
      # Create the base model from the pre-trained model MobileNet V2
      IMG_SHAPE = IMG_SIZE + (3,)
      base_model = tf.keras.applications.MobileNetV2(
          input_shape=IMG_SHAPE, include_top=False, weights="imagenet"
      )
  
      image_batch, label_batch = next(iter(train_dataset))
      feature_batch = base_model(image_batch)
      print(feature_batch.shape)
  
      base_model.trainable = False
  
      # Let's take a look at the base model architecture
      base_model.summary()
  
      global_average_layer = tf.keras.layers.GlobalAveragePooling2D()
      feature_batch_average = global_average_layer(feature_batch)
      print(feature_batch_average.shape)
  
      prediction_layer = tf.keras.layers.Dense(1)
      prediction_batch = prediction_layer(feature_batch_average)
      print(prediction_batch.shape)
  
      inputs = tf.keras.Input(shape=(160, 160, 3))
      x = data_augmentation(inputs)
      x = preprocess_input(x)
      x = base_model(x, training=False)
      x = global_average_layer(x)
      x = tf.keras.layers.Dropout(0.2)(x)
      outputs = prediction_layer(x)
      model = tf.keras.Model(inputs, outputs)
  
      base_learning_rate = 0.0001
      model.compile(
          optimizer=tf.keras.optimizers.Adam(lr=base_learning_rate),
          loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
          metrics=["accuracy"],
      )
  
      model.summary()
  
      print(
          "Number of trainable variables:",
          len(model.trainable_variables),
      )
  
      initial_epochs = 10
  
      loss0, accuracy0 = model.evaluate(validation_dataset)
  
      print("initial loss: {:.2f}".format(loss0))
      print("initial accuracy: {:.2f}".format(accuracy0))
  
      history = model.fit(
          train_dataset,
          epochs=initial_epochs,
          validation_data=validation_dataset,
      )
  
      base_model.trainable = True
  
      # Let's take a look to see how many layers are in the base model
      print(
          "Number of layers in the base model: ", len(base_model.layers)
      )
  
      # Fine-tune from this layer onwards
      fine_tune_at = 100
  
      # Freeze all the layers before the `fine_tune_at` layer
      for layer in base_model.layers[:fine_tune_at]:
          layer.trainable = False
  
      model.compile(
          loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
          optimizer=tf.keras.optimizers.RMSprop(
              lr=base_learning_rate / 10
          ),
          metrics=["accuracy"],
      )
  
      model.summary()
  
      print(
          "Number of trainable variables now:",
          len(model.trainable_variables),
      )
  
      fine_tune_epochs = 10
      total_epochs = initial_epochs + fine_tune_epochs
  
      history_fine = model.fit(
          train_dataset,
          epochs=total_epochs,
          initial_epoch=history.epoch[-1],
          validation_data=validation_dataset,
      )
  
      loss, accuracy = model.evaluate(test_dataset)
      print("Test accuracy :", accuracy)
  
imports: import numpy
  import os
  import tensorflow
  from tensorflow.keras.preprocessing import image_dataset_from_directory
  from bigdl.nano.tf.keras import Sequential
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types