class_docstr: Computes the crossentropy metric between the labels and predictions.
  This is used when there are only two labels (0 and 1).
  
  Usage:
  
  ```python
  pred = torch.tensor([[0.6, 0.4], [0.4, 0.6]])
  target = torch.tensor([[0, 1], [0, 0]])
  entropy = BinaryCrossEntropy()
  entropy(pred, target)
  assert abs(entropy.compute() - 0.81492424) < 1e-6
  ```
class_docstr_tok: ["Computes","the","crossentropy","metric","between","the","labels","and","predictions",".","This","is","used","when","there","are","only","two","labels","(","0","and","1",")",".","Usage",":","``","`","python","pred","=","torch.tensor","(","[","[","0.6",",","0.4","]",",","[","0.4",",","0.6","]","]",")","target","=","torch.tensor","(","[","[","0",",","1","]",",","[","0",",","0","]","]",")","entropy","=","BinaryCrossEntropy","(",")","entropy","(","pred",",","target",")","assert","abs","(","entropy.compute","(",")","-","0.81492424",")","<","1e-6","``","`"]
code: def __call__(self, preds, targets):
      # Avoid problems with logarithm
      epsilon = 1e-7
      preds[preds <= 0] = epsilon
      preds[preds >= 1] = 1 - epsilon
  
      output_size = targets.view(-1).size(0)
      self.crossentropy = (
          self.crossentropy
          + (
              -targets * torch.log(preds)
              - (1 - targets) * torch.log(1 - preds)
          )
          .view(-1)
          .sum()
      )
      self.total += output_size
  
imports: import torch
  from abc import ABC, abstractmethod
label_desc: Use image node_id 2 for calling the BinaryCrossEntropy obj's underlying member method code with example usage: obj.__call__(preds, targets) without return types