code: def set_reference_images(
      self, images_PIL, masks_PIL, heatmaps, id_features
  ):
      assert len(images_PIL) != 0 and len(images_PIL) <= self.batch_size
      loaded_image = load_images(
          images_PIL, self.img_size, sharpen=self.sharpen_input
      )
      loaded_mask = load_images(
          masks_PIL,
          self.img_size,
          sharpen=self.sharpen_input,
          im_type="L",
      )
      heatmaps = np.transpose(np.array(heatmaps), [0, 2, 3, 1])
      input_size = np.array(heatmaps).shape[2]
      output_size = int(self.ref_heatmaps.shape[1])
      bin_size = input_size // output_size
      loaded_heatmaps = (
          heatmaps.reshape(
              (
                  heatmaps.shape[0],
                  output_size,
                  bin_size,
                  output_size,
                  bin_size,
                  68,
              )
          )
          .max(4)
          .max(2)
      )
      image_features = None
      if self.perceptual_model is not None:
          image_features = self.perceptual_model.predict_on_batch(
              preprocess_input(np.array(loaded_image))
          )
          weight_mask = np.ones(self.features_weight.shape)
  
      if self.face_mask:
          image_mask = np.zeros(self.ref_weight.shape)
          for i, (im, mask) in enumerate(
              zip(loaded_image, loaded_mask)
          ):
              try:
                  mask = np.array(mask) / 255
                  mask = np.expand_dims(mask, axis=-1)
                  mask = np.ones(im.shape, np.float32) * mask  # ?
              except Exception as e:
                  print("Exception in mask handling for mask")
                  traceback.print_exc()
                  mask = np.ones(im.shape[:2], np.uint8)
                  mask = np.ones(im.shape, np.float32) * np.expand_dims(
                      mask, axis=-1
                  )
              image_mask[i] = mask
          img = None
      else:
          image_mask = np.ones(self.ref_weight.shape)
  
      if len(images_PIL) != self.batch_size:
          if image_features is not None:
              features_space = list(self.features_weight.shape[1:])
              existing_features_shape = [
                  len(images_PIL)
              ] + features_space
              empty_features_shape = [
                  self.batch_size - len(images_PIL)
              ] + features_space
              existing_examples = np.ones(shape=existing_features_shape)
              empty_examples = np.zeros(shape=empty_features_shape)
              weight_mask = np.vstack(
                  [existing_examples, empty_examples]
              )
              image_features = np.vstack(
                  [image_features, np.zeros(empty_features_shape)]
              )
  
          images_space = list(self.ref_weight.shape[1:])
          existing_images_space = [len(images_PIL)] + images_space
          empty_images_space = [
              self.batch_size - len(images_PIL)
          ] + images_space
          existing_images = np.ones(shape=existing_images_space)
          empty_images = np.zeros(shape=empty_images_space)
          image_mask = image_mask * np.vstack(
              [existing_images, empty_images]
          )
          loaded_image = np.vstack(
              [loaded_image, np.zeros(empty_images_space)]
          )
  
      if image_features is not None:
          self.assign_placeholder("features_weight", weight_mask)
          self.assign_placeholder("ref_img_features", image_features)
      self.assign_placeholder("ref_weight", image_mask)
      self.assign_placeholder("ref_img", loaded_image)
      self.assign_placeholder("org_features", id_features)
      self.assign_placeholder("ref_heatmaps", loaded_heatmaps)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import tensorflow
  import bz2
  import PIL.Image
  from PIL import ImageFilter
  import numpy
  from keras.models import Model
  from keras.applications.vgg16 import VGG16, preprocess_input
  import keras.backend
  import traceback
  import external.stylegan2.dnnlib.tflib
  from core.landmark_handler import Landmark_Handler
  from core import arcface_handler
label_desc: Use image node_id 5 for calling the PerceptualModel obj's underlying member method code with example usage: obj.set_reference_images(images_PIL, masks_PIL, heatmaps, id_features) without return types