code: def _entropy_loss(distributions, spec, weights=None):
      """Computes entropy loss.
  
      Args:
        distributions: A possibly batched tuple of distributions.
        spec: A nested tuple representing the action spec.
        weights: Optional scalar or element-wise (per-batch-entry) importance
          weights.  Includes a mask for invalid timesteps.
  
      Returns:
        A Tensor representing the entropy loss.
      """
      with tf.name_scope("entropy_regularization"):
          entropy = -tf.cast(
              common.entropy(distributions, spec), tf.float32
          )
          if weights is not None:
              entropy *= weights
          return tf.reduce_mean(input_tensor=entropy)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Callable, Optional, Text
  import gin
  import numpy
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.networks import network
  from tf_agents.policies import actor_policy
  from tf_agents.policies import greedy_policy
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import eager_utils
  from tf_agents.utils import nest_utils
  from tf_agents.utils import value_ops
label_desc: Use image node_id 2 for calling a global function with example usage: _entropy_loss(distributions, spec, weights) and returns: tf