code: def _brevity_penalty(ref_length, trans_length):
      
      if trans_length > ref_length:
          return 1
      # If translation is empty, brevity penalty = 0 should result in BLEU = 0.0
      elif trans_length == 0:
          return 0
      else:
          return math.exp(1 - float(ref_length) / trans_length)
docs: Calculate brevity penalty.
  
      Parameters
      ----------
      ref_length: int
          Sum of all closest references'lengths for every translations in a corpus
      trans_length: int
          Sum of all translations's lengths in a corpus.
  
      Returns
      -------
      bleu's brevity penalty: float