code: def _build_placeholders_from_specs(
      dtypes, shapes, force_dynamic_num_graphs=True
  ):
      """Creates a `graphs.GraphsTuple` of placeholders with `dtypes` and `shapes`.
  
      The dtypes and shapes arguments are instances of `graphs.GraphsTuple` that
      contain dtypes and shapes, or `None` values for the fields for which no
      placeholder should be created. The leading dimension the nodes and edges are
      dynamic because the numbers of nodes and edges can vary.
      If `force_dynamic_num_graphs` is True, then the number of graphs is assumed to
      be dynamic and all fields leading dimensions are set to `None`.
      If `force_dynamic_num_graphs` is False, then `N_NODE`, `N_EDGE` and `GLOBALS`
      leading dimensions are statically defined.
  
      Args:
        dtypes: A `graphs.GraphsTuple` that contains `tf.dtype`s or `None`s.
        shapes: A `graphs.GraphsTuple` that contains `list`s of integers,
          `tf.TensorShape`s, or `None`s.
        force_dynamic_num_graphs: A `bool` that forces the batch dimension to be
          dynamic. Defaults to `True`.
  
      Returns:
        A `graphs.GraphsTuple` containing placeholders.
  
      Raises:
        ValueError: The `None` fields in `dtypes` and `shapes` do not match.
      """
      dct = {}
      for field in ALL_FIELDS:
          dtype = getattr(dtypes, field)
          shape = getattr(shapes, field)
          if dtype is None or shape is None:
              if not (shape is None and dtype is None):
                  raise ValueError(
                      "only one of dtype and shape are None for field {}".format(
                          field
                      )
                  )
              dct[field] = None
          elif not shape:
              raise ValueError("Shapes must have at least rank 1")
          else:
              shape = list(shape)
              if (
                  field not in [N_NODE, N_EDGE, GLOBALS]
                  or force_dynamic_num_graphs
              ):
                  shape[0] = None
  
              dct[field] = tf.placeholder(
                  dtype, shape=shape, name=field
              )
  
      return graphs.GraphsTuple(**dct)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import functools
  from absl import logging
  from graph_nets import graphs
  from graph_nets import utils_np
  import six
  from six.moves import range
  import tensorflow
  import tree
label_desc: Use image node_id 2 for calling a global function with example usage: _build_placeholders_from_specs(dtypes, shapes, force_dynamic_num_graphs) and returns: graphs