code: def estimate_entropy(
      entropy_model, inputs, spatial_shape=None
  ) -> EntropyInfo:
      """Compresses `inputs` with the given entropy model and estimates entropy.
  
      Args:
        entropy_model: An `EntropyModel` instance.
        inputs: The input tensor to be fed to the entropy model.
        spatial_shape: Shape of the input image (HxW). Must be provided for
          `valid == False`.
  
      Returns:
        The 'noisy' and quantized inputs, as well as differential and discrete
        entropy estimates, as an `EntropyInfo` named tuple.
      """
      # We are summing over the log likelihood tensor, so we need to explicitly
      # divide by the batch size.
      batch = tf.cast(tf.shape(inputs)[0], tf.float32)
  
      # Divide by this to flip sign and convert from nats to bits.
      quotient = tf.constant(-np.log(2), dtype=tf.float32)
  
      num_pixels = tf.cast(tf.reduce_prod(spatial_shape), tf.float32)
  
      # Compute noisy outputs and estimate differential entropy.
      noisy, likelihood = entropy_model(inputs, training=True)
      log_likelihood = tf.log(likelihood)
      nbits = tf.reduce_sum(log_likelihood) / (quotient * batch)
      nbpp = nbits / num_pixels
  
      # Compute quantized outputs and estimate discrete entropy.
      quantized, likelihood = entropy_model(inputs, training=False)
      log_likelihood = tf.log(likelihood)
      qbits = tf.reduce_sum(log_likelihood) / (quotient * batch)
      qbpp = qbits / num_pixels
  
      return EntropyInfo(noisy, quantized, nbits, nbpp, qbits, qbpp)
  
imports: import collections
  from compare_gan.architectures import abstract_arch
  from compare_gan.architectures import arch_ops
  import numpy
  import tensorflow.compat.v1
  import tensorflow_compression
  from hific.helpers import ModelMode
label_desc: Use image node_id 2 for calling a global function with example usage: estimate_entropy(entropy_model, inputs, spatial_shape) and returns: EntropyInfo