code: def compress_image(model, input_image, rd_parameter=None):
      """Compresses an image tensor into a bitstring."""
      sender = instantiate_model_signature(model, "sender")
      if len(sender.inputs) == 1:
          if rd_parameter is not None:
              raise ValueError(
                  "This model doesn't expect an RD parameter."
              )
          tensors = sender(input_image)
      elif len(sender.inputs) == 2:
          if rd_parameter is None:
              raise ValueError("This model expects an RD parameter.")
          rd_parameter = tf.constant(
              rd_parameter, dtype=sender.inputs[1].dtype
          )
          tensors = sender(input_image, rd_parameter)
          # Find RD parameter and expand it to a 1D tensor so it fits into the
          # PackedTensors format.
          for i, t in enumerate(tensors):
              if t.dtype.is_floating and t.shape.rank == 0:
                  tensors[i] = tf.expand_dims(t, 0)
      else:
          raise RuntimeError("Unexpected model signature.")
      packed = tfc.PackedTensors()
      packed.model = model
      packed.pack(tensors)
      return packed.string
  
imports: import argparse
  import io
  import os
  import sys
  import urllib
  from absl import app
  from absl.flags import argparse_flags
  import numpy
  import tensorflow
  import tensorflow_compression
label_desc: Use image node_id 5 for calling a global function with example usage: compress_image(model, input_image, rd_parameter) and returns: packed