code: def binary_cross_entropy(labels, preds, fromLogits):
      """Calculates binary cross-entropy for two blobs: the first one contains labels, the second one contains predictions.
      Blobs should be of the same shape.
      :math:`result = (1 - labels) * x + log(1 + exp(-x))`
      if `fromLogits` then `x = preds`, else :math:`x = log( clippedPreds / (1 - clippedPreds))`
      """
      if not type(labels) is Blob:
          raise ValueError("`labels` should be neoml.Blob.")
  
      if not type(preds) is Blob:
          raise ValueError("`preds` should be neoml.Blob.")
  
      if labels.shape != preds.shape:
          raise ValueError("The blobs should be of the same shape.")
  
      if labels.size == 0:
          raise ValueError("The blobs shouldn't be empty.")
  
      return Blob(
          PythonWrapper.blob_binary_cross_entropy(
              labels._internal, preds._internal, bool(fromLogits)
          )
      )
  
imports: import neoml
  import neoml.PythonWrapper
  from neoml.MathEngine import MathEngine
  from neoml.Blob import Blob
  import numpy
label_desc: Use image node_id 21 for calling a global function with example usage: binary_cross_entropy(labels, preds, fromLogits) and returns: Blob