code: def resize_to_model_input(model, input_index=0):
      assert keras is not None
      assert isinstance(model, keras.models.Model) or isinstance(
          model, keras.models.Sequential
      )
  
      input_shape = tuple(
          [x.value for x in model.inputs[input_index].shape if x.value]
      )
      assert len(input_shape) == 3
  
      if len(input_shape) == 3:
          assert (
              input_shape[0] == 1
              or input_shape[2] == 1
              or input_shape[0] == 3
              or input_shape[2] == 3
          )
  
          if input_shape[0] == 1 or input_shape[0] == 3:
              data_format = "channels_first"
          else:
              data_format = "channels_last"
  
      def _run_resize(input_img):
          if input_img is None:
              return None
          if len(input_shape) == 3:
              img = input_img.resize(
                  (input_shape[1], input_shape[0]), Image.ANTIALIAS
              )
  
          arr = image_prep.img_to_array(img, data_format)
          arr /= 255.0
  
          if input_shape[0] == 1 and arr.shape[0] > 1:
              arr = np.mean(arr, axis=0)
  
          if input_shape[2] == 1 and arr.shape[2] > 1:
              arr = np.mean(arr, axis=2)
  
          return arr.reshape((1,) + input_shape)
  
      return _run_resize
  
imports: import types
  from studio.util import logs
  from PIL import Image
  from threading import Thread
  import numpy
  import itertools
  import six
label_desc: Use image node_id 1 for calling a global function with example usage: resize_to_model_input(model, input_index) and returns: _run_resize, arr, None