class_docstr: Create a sphinx gallery style thumbnail.
  tooltip and figure are self explanatory. Description could be a link to
  a document like in below example.
  Example usage:
  .. customgalleryitem::
      :tooltip: I am writing this tutorial to focus specifically on NLP for people who have never written code in any deep learning framework
      :figure: /_static/img/thumbnails/babel.jpg
      :description: :doc:`/beginner/deep_learning_nlp_tutorial`
  If figure is specified, a thumbnail will be made out of it and stored in
  _static/thumbs. Therefore, consider _static/thumbs as a 'built' directory.
class_docstr_tok: ["Create","a","sphinx","gallery","style","thumbnail",".","tooltip","and","figure","are","self","explanatory",".","Description","could","be","a","link","to","a","document","like","in","below","example",".","Example","usage",":","..","customgalleryitem",":",":",":","tooltip",":","I","am","writing","this","tutorial","to","focus","specifically","on","NLP","for","people","who","have","never","written","code","in","any","deep","learning","framework",":","figure",":","\/_static\/img\/thumbnails\/babel.jpg",":","description",":",":","doc",":","`","\/beginner\/deep_learning_nlp_tutorial","`","If","figure","is","specified",",","a","thumbnail","will","be","made","out","of","it","and","stored","in","_static\/thumbs",".","Therefore",",","consider","_static\/thumbs","as","a","'built","'","directory","."]
code: def run(self):
      try:
          if "tooltip" in self.options:
              tooltip = self.options["tooltip"][:195] + "..."
          else:
              raise ValueError("tooltip not found")
  
          if "figure" in self.options:
              env = self.state.document.settings.env
              rel_figname, figname = env.relfn2path(
                  self.options["figure"]
              )
              thumbnail = os.path.join(
                  "_static/thumbs/", os.path.basename(figname)
              )
  
              try:
                  os.makedirs("_static/thumbs")
              except FileExistsError:
                  pass
  
              sphinx_gallery.gen_rst.scale_image(
                  figname, thumbnail, 400, 280
              )
          else:
              thumbnail = "_static/img/thumbnails/default.png"
  
          if "description" in self.options:
              description = self.options["description"]
          else:
              raise ValueError("description not doc found")
  
      except FileNotFoundError as e:
          print(e)
          return []
      except ValueError as e:
          print(e)
          raise
          return []
  
      thumbnail_rst = GALLERY_TEMPLATE.format(
          tooltip=tooltip, thumbnail=thumbnail, description=description
      )
      thumbnail = StringList(thumbnail_rst.split("\n"))
      thumb = nodes.paragraph()
      self.state.nested_parse(thumbnail, self.content_offset, thumb)
      return [thumb]
  
file_path: mlens/docs/source/custom_directives.py
imports: from docutils.parsers.rst import Directive, directives
  from docutils.statemachine import StringList
  from docutils import nodes
  import re
  import os
  import sphinx_gallery
label_desc: Use image node_id 1 for calling the CustomGalleryItemDirective obj's underlying member method code with example usage: obj.run() and returns: list, list, list