def _convert_to_tf_example(example,
                           rules,
                           rhs_emb_idx_map,
                           lhs_emb_idx_map,
                           config,
                           max_sizes=None):
  """Return tf.Example generated for input (source, target)."""
  source, target = example
  (node_type_list, node_idx_list, rhs_emb_idx_list, lhs_emb_idx_list,
   num_nodes) = get_input_features(source, target, rules, rhs_emb_idx_map,
                                   lhs_emb_idx_map, config)

  # Create features dict.
  features = collections.OrderedDict()

  features["node_type_list"] = _create_int_seq_feature(
      [node_type_list], 1, config["max_num_numerator_nodes"])
  features["node_idx_list"] = _create_int_seq_feature(
      _transpose(node_idx_list), config["max_num_nts"],
      config["max_num_numerator_nodes"])
  features["rhs_emb_idx_list"] = _create_int_seq_feature(
      _transpose(rhs_emb_idx_list), config["max_num_nts"],
      config["max_num_numerator_nodes"])
  features["lhs_emb_idx_list"] = _create_int_seq_feature(
      _transpose(lhs_emb_idx_list), config["max_num_nts"],
      config["max_num_numerator_nodes"])
  features["num_nodes"] = _create_int_seq_feature([[num_nodes]], 1, 1)

  tf_example = tf.train.SequenceExample(
      feature_lists=tf.train.FeatureLists(feature_list=features))

  # Update max sizes.
  if max_sizes is not None:
    max_sizes["num_nodes"] = max(max_sizes["num_nodes"], num_nodes)

  return tf_example
Return tf.Example generated for input (source, target).
language/compgen/csl/model/data/example_converter.py