class_docstr: This class loads in the sentences and CNN image features for image captioning
  that have been taken from Andrej Karpathy's
  `Deep Visual-Semantic Alignments <http://cs.stanford.edu/people/karpathy/deepimagesent/>`_
  work. They are converted to pkl format to avoid using scipy for loading the .mat
  image features.
  
  The dataset assumes the model takes the precomputed VGG features of an
  image and a sentence converted to its one hot representation. The model
  then transforms both the image and the sentence to the same space and
  prepends the image to the sentence so that it is treated as the first word
  of the sequence to be fed to a RNN.
docstr: Compute the BLEU score from a list of predicted sentences and reference sentences
  
  Args:
      sents (list): list of predicted sentences
      targets (list): list of reference sentences where each element is a list of
                      multiple references.
code: def bleu_score(self, sents, targets):
      """
      Compute the BLEU score from a list of predicted sentences and reference sentences
  
      Args:
          sents (list): list of predicted sentences
          targets (list): list of reference sentences where each element is a list of
                          multiple references.
      """
  
      num_ref = len(targets[0])
      output_file = self.path + "/output"
      reference_files = [
          self.path + "/reference%d" % i for i in range(num_ref)
      ]
      bleu_script_url = "https://raw.githubusercontent.com/karpathy/neuraltalk/master/eval/"
      bleu_script = "multi-bleu.perl"
  
      neon_logger.display(
          "Writing output and reference sents to dir %s" % self.path
      )
  
      output_f = open(output_file, "w+")
      for sent in sents:
          sent = sent.strip(self.end_token).split()
          output_f.write(" ".join(sent) + "\n")
  
      reference_f = [open(f, "w") for f in reference_files]
      for i in range(num_ref):
          for target_sents in targets:
              reference_f[i].write(target_sents[i] + "\n")
  
      output_f.close()
      [x.close() for x in reference_f]
  
      owd = os.getcwd()
      os.chdir(self.path)
      if not os.path.exists(bleu_script):
          Dataset.fetch_dataset(
              bleu_script_url, bleu_script, bleu_script, 6e6
          )
      bleu_command = "perl multi-bleu.perl reference < output"
      neon_logger.display(
          "Executing bleu eval script: {}".format(bleu_command)
      )
      os.system(bleu_command)
      os.chdir(owd)
  
imports: from collections import Counter
  import numpy
  import os
  from neon import logger
  from neon.data.dataiterator import NervanaDataIterator
  from neon.data.datasets import Dataset
  from neon.util.compat import xrange
label_desc: Use image node_id 7 for calling the ImageCaption obj's underlying member method code with example usage: obj.bleu_score(sents, targets) without return types