import collections


def _test_spinn_config(d_embed, d_out, logdir=None, inference_sentences=None):
  """Generate a config tuple for testing.

  Args:
    d_embed: Embedding dimensions.
    d_out: Model output dimensions.
    logdir: Optional logdir.
    inference_sentences: A 2-tuple of strings representing the sentences (with
      binary parsing result), e.g.,
      ("( ( The dog ) ( ( is running ) . ) )", "( ( The dog ) ( moves . ) )").

  Returns:
    A config tuple.
  """
  config_tuple = collections.namedtuple(
      "Config", ["d_hidden", "d_proj", "d_tracker", "predict",
                 "embed_dropout", "mlp_dropout", "n_mlp_layers", "d_mlp",
                 "d_out", "projection", "lr", "batch_size", "epochs",
                 "force_cpu", "logdir", "log_every", "dev_every", "save_every",
                 "lr_decay_every", "lr_decay_by", "inference_premise",
                 "inference_hypothesis"])

  inference_premise = inference_sentences[0] if inference_sentences else None
  inference_hypothesis = inference_sentences[1] if inference_sentences else None
  return config_tuple(
      d_hidden=d_embed,
      d_proj=d_embed * 2,
      d_tracker=8,
      predict=False,
      embed_dropout=0.1,
      mlp_dropout=0.1,
      n_mlp_layers=2,
      d_mlp=32,
      d_out=d_out,
      projection=True,
      lr=2e-2,
      batch_size=2,
      epochs=20,
      force_cpu=False,
      logdir=logdir,
      log_every=1,
      dev_every=2,
      save_every=2,
      lr_decay_every=1,
      lr_decay_by=0.75,
      inference_premise=inference_premise,
      inference_hypothesis=inference_hypothesis)