class_docstr: Layer to calibrate the model outputs.
  
  The class implements the heuristics described in :cite:`calibration`,
  using Platt scaling :cite:`platt1999probabilistic`.
  
  See the docs of :meth:`~ampligraph.latent_features.models.ScoringBasedEmbeddingModel.calibrate()` for more details.
docstr: Call method.
docstr_tok: ["Call","method","."]
code: def call(self, scores_pos, scores_neg=[], training=0):
      """
      Call method.
      """
      if training:
          scores_all = tf.concat([scores_pos, scores_neg], axis=0)
      else:
          scores_all = scores_pos
  
      logits = -(self.calib_w * scores_all + self.calib_b)
  
      if training:
          labels = tf.concat(
              [
                  tf.cast(
                      tf.fill(
                          scores_pos.shape,
                          (self.pos_size + 1.0) / (self.pos_size + 2.0),
                      ),
                      tf.float32,
                  ),
                  tf.cast(
                      tf.fill(
                          scores_neg.shape, 1 / (self.neg_size + 2.0)
                      ),
                      tf.float32,
                  ),
              ],
              axis=0,
          )
          weigths_pos = scores_neg.shape[0] / scores_pos.shape[0]
          weights_neg = (
              1.0 - self.positive_base_rate
          ) / self.positive_base_rate
          weights = tf.concat(
              [
                  tf.cast(
                      tf.fill(scores_pos.shape, weigths_pos), tf.float32
                  ),
                  tf.cast(
                      tf.fill(scores_neg.shape, weights_neg), tf.float32
                  ),
              ],
              axis=0,
          )
          loss = tf.reduce_mean(
              weights
              * tf.nn.sigmoid_cross_entropy_with_logits(labels, logits)
          )
          return loss
      else:
          return tf.math.sigmoid(logits)
  
imports: import tensorflow
label_desc: Use image node_id 4 for calling the CalibrationLayer obj's underlying member method code with example usage: obj.call(scores_pos, scores_neg, training) and returns: loss, tf