code: def _weight_memory_size(weights):
      """Calculate the memory footprint for weights based on their dtypes.
  
      Args:
          weights: An iterable contains the weights to compute weight size.
  
      Returns:
          The total memory size (in Bytes) of the weights.
      """
      unique_weights = {id(w): w for w in weights}.values()
  
      total_memory_size = 0
      for w in unique_weights:
          # Ignore TrackableWeightHandlers, which will not have a shape defined.
          if not hasattr(w, "shape"):
              continue
          elif None in w.shape.as_list():
              continue
          weight_shape = np.prod(w.shape.as_list())
          per_param_size = w.dtype.size
          total_memory_size += weight_shape * per_param_size
      return total_memory_size
  
file_path: agents/tf_agents/networks/layer_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import re
  import numpy
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _weight_memory_size(weights) and returns: total_memory_size