code: def compute_loss(self, logits, y):
      sigmoid_logits = tf.nn.sigmoid(logits)
  
      neg_y = 1.0 - y
      pos_logits = y * logits
  
      pos_max = tf.reduce_max(pos_logits, axis=1)
      pos_max = tf.expand_dims(pos_max, axis=-1)
  
      pos_min = tf.reduce_min(pos_logits + neg_y * pos_max, axis=1)
      pos_min = tf.expand_dims(pos_min, axis=-1)
  
      nb_pos, nb_neg = tf.count_nonzero(y, axis=1), tf.count_nonzero(
          neg_y, axis=1
      )
      ratio = tf.cast(nb_neg, dtype=tf.float32) / tf.cast(
          nb_pos, dtype=tf.float32
      )
  
      pos_weight = tf.expand_dims(ratio, axis=-1)
      loss = y * -tf.log(sigmoid_logits) * pos_weight + neg_y * -tf.log(
          1.0 - tf.nn.sigmoid(logits - pos_min)
      )
  
      return tf.reduce_mean(loss + 1e-8)
  
file_path: cornac/cornac/models/beacon/beacon_tf.py
imports: import numpy
  import warnings
  import tensorflow.compat.v1
label_desc: Use image node_id 7 for calling the BeaconModel obj's underlying member method code with example usage: obj.compute_loss(logits, y) and returns: tf