code: def _interactive_input_tensor_to_features_dict(feature_map, hparams):
      """Convert the interactive input format (see above) to a dictionary.
  
      Args:
        feature_map: dict with inputs.
        hparams: model hyperparameters
  
      Returns:
        a features dictionary, as expected by the decoder.
      """
      inputs = tf.convert_to_tensor(feature_map["inputs"])
      input_is_image = False if len(inputs.get_shape()) < 3 else True
  
      x = inputs
      if input_is_image:
          x = tf.image.resize_images(x, [299, 299])
          x = tf.reshape(x, [1, 299, 299, -1])
          x = tf.to_int32(x)
      else:
          # Remove the batch dimension.
          num_samples = x[0]
          length = x[2]
          x = tf.slice(x, [3], tf.to_int32([length]))
          x = tf.reshape(x, [1, -1, 1, 1])
          # Transform into a batch of size num_samples to get that many random
          # decodes.
          x = tf.tile(x, tf.to_int32([num_samples, 1, 1, 1]))
  
      p_hparams = hparams.problem_hparams
      input_space_id = tf.constant(p_hparams.input_space_id)
      target_space_id = tf.constant(p_hparams.target_space_id)
  
      features = {}
      features["input_space_id"] = input_space_id
      features["target_space_id"] = target_space_id
      features["decode_length"] = (
          IMAGE_DECODE_LENGTH if input_is_image else inputs[1]
      )
      features["inputs"] = x
      # Save inputs to "partial_targets" when prepending inputs to targets. Also
      # keep "inputs" as some models crash if they don't exist.
      if getattr(hparams, "prepend_mode", "none") != "none":
          shape = tf.shape(x)
          partial_targets = tf.reshape(x, [shape[0], shape[1]])
          partial_targets = tf.pad(partial_targets, [[0, 0], [0, 1]])
          features["partial_targets"] = partial_targets
      return features
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import operator
  import os
  import re
  import string
  import time
  import numpy
  import six
  from six.moves import input
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import text_encoder
  from tensor2tensor.data_generators import text_problems
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import hparam
  from tensor2tensor.utils import mlperf_log
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 17 for calling a global function with example usage: _interactive_input_tensor_to_features_dict(feature_map, hparams) and returns: features