class_docstr: The :class:`ImagingCallback` provides a generic interface for callbacks which yield images that should be sent to
  a file, tensorboard, visdom etc. without needing bespoke code. This allows the user to easily define custom
  visualisations by only writing the code to produce the image.
  
  Args:
      transform (callable, optional): A function/transform that  takes in a Tensor and returns a transformed version.
          This will be applied to the image before it is sent to output.
class_docstr_tok: ["The",":","class",":","`","ImagingCallback","`","provides","a","generic","interface","for","callbacks","which","yield","images","that","should","be","sent","to","a","file",",","tensorboard",",","visdom","etc",".","without","needing","bespoke","code",".","This","allows","the","user","to","easily","define","custom","visualisations","by","only","writing","the","code","to","produce","the","image",".","Args",":","transform","(","callable",",","optional",")",":","A","function\/transform","that","takes","in","a","Tensor","and","returns","a","transformed","version",".","This","will","be","applied","to","the","image","before","it","is","sent","to","output","."]
docstr: Put images from this callback in state with the given key
  
  Args:
      keys (StateKey or list[StateKey]): The state key or keys to use for the images
      index (int or list or None): If not None, only apply the handler on this index / list of indices
  
  Returns:
      ImagingCallback: self
docstr_tok: ["Put","images","from","this","callback","in","state","with","the","given","key","Args",":","keys","(","StateKey","or","list","[","StateKey","]",")",":","The","state","key","or","keys","to","use","for","the","images","index","(","int","or","list","or","None",")",":","If","not","None",",","only","apply","the","handler","on","this","index","\/","list","of","indices","Returns",":","ImagingCallback",":","self"]
code: def to_state(self, keys, index=None):
      """Put images from this callback in state with the given key
  
      Args:
          keys (StateKey or list[StateKey]): The state key or keys to use for the images
          index (int or list or None): If not None, only apply the handler on this index / list of indices
  
      Returns:
          ImagingCallback: self
      """
      if str(keys) == keys:
          keys = [keys]
  
      try:
          _ = (key for key in keys)
      except TypeError:
          keys = [keys]
  
      def handler(img, i, state):
          state[keys[i]] = img
  
      return self.with_handler(handler, index=index)
  
imports: import torchbearer
  from torchbearer import Callback
  import torch
label_desc: Use image node_id 10 for calling the ImagingCallback obj's underlying member method code with example usage: obj.to_state(keys, index) and returns: self