def assign_tensor_placeholders(placeholder_dict, data_dict):
    """
    Builds feed dictionary for Tensorflow from the placeholder
    dictionary, which holds placeholders of all gates in the circuit,
    and a global data dictionary.

    Parameters
    ----------
    placeholder_dict : dict
           Dictionary of {tensorflow.placeholder : data_key} pairs
    data_dict : dict
           Dictionary of {data_key : np.array} pairs

    Returns
    -------
    feed_dict : dict
          Dictionary to feed in Tensorflow session
    """
    feed_dict = {}
    for placeholder, data_key in placeholder_dict.items():
        try:
            feed_dict[placeholder] = data_dict[data_key]
        except KeyError:
            pass
    return feed_dict
