def create_model(model, labels, num_choices):
  """Creates a classification model.

  Args:
    model: the BERT model from modeling.py
    labels: ground truth paragraph order
    num_choices: number of negatives samples + 1

  Returns:
    tuple of (loss, per_example_loss, logits, probabilities) for model
  """

  output_layer = model.get_pooled_output()

  hidden_size = output_layer.shape[-1].value

  dense_layer_weights = tf.get_variable(
      "dense_layer", [(1 + num_choices) * hidden_size, num_choices],
      initializer=tf.truncated_normal_initializer(stddev=0.02))

  with tf.variable_scope("cpc_loss"):
    example_repr = tf.reshape(output_layer,
                              (-1, (num_choices + 1) * hidden_size))
    logits = tf.matmul(example_repr, dense_layer_weights)

    per_example_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(
        logits=logits, labels=labels)
    probabilities = tf.nn.softmax(logits, axis=-1)
    loss = tf.reduce_mean(per_example_loss)

  return (loss, per_example_loss, logits, probabilities)
Creates a classification model.

  Args:
    model: the BERT model from modeling.py
    labels: ground truth paragraph order
    num_choices: number of negatives samples + 1

  Returns:
    tuple of (loss, per_example_loss, logits, probabilities) for model
  
language/conpono/evals/model_builder.py