class_docstr: This class creates a ``tf.data.Dataset`` instance from
  a sampler's layer_op function or generator.
  
  If ``from_generator``, ``Dataset.from_generator`` interface will be used,
  ``Dataset.map`` interface will be used otherwise::
  
      if the windows are from a image reader,
      the total number of windows produced
      will be: `epoch x n_subjects x windows_per_image`
  
      if the windows are from a generator,
      the total number of windows produced
      will be: "iterations from the generator" x num_threads
class_docstr_tok: ["This","class","creates","a","``","tf.data.Dataset","``","instance","from","a","sampler","'s","layer_op","function","or","generator",".","If","``","from_generator","``",",","``","Dataset.from_generator","``","interface","will","be","used",",","``","Dataset.map","``","interface","will","be","used","otherwise",":",":","if","the","windows","are","from","a","image","reader",",","the","total","number","of","windows","produced","will","be",":","`","epoch","x","n_subjects","x","windows_per_image","`","if","the","windows","are","from","a","generator",",","the","total","number","of","windows","produced","will","be",":","``","iterations","from","the","generator","''","x","num_threads"]
docstr: Generating each image as a window.
  Overriding this function to create new image sampling strategies.
  
  This function should either yield or return a dictionary
  (of multiple windows per image)::
  
      return a dictionary:
      {
       'image_name': a numpy array [n_samples, h, w, d, chn],
       'image_name_location': [n_samples, 7]
      }
  
  where the 7-element location vector encode the image_id,
  starting and ending coordinates of the image window.
  
  Following the same notation, the dictionary can be extended
  to multiple modalities; the keys will be::
  
      {'image_name_1', 'image_name_1_location',
       'image_name_2', 'image_name_2_location', ...}
  
  :param idx: image_id used to load the image at the i-th row of
      the input
  :return: a image data dictionary
docstr_tok: ["Generating","each","image","as","a","window",".","Overriding","this","function","to","create","new","image","sampling","strategies",".","This","function","should","either","yield","or","return","a","dictionary","(","of","multiple","windows","per","image",")",":",":","return","a","dictionary",":","{","'image_name","'",":","a","numpy","array","[","n_samples",",","h",",","w",",","d",",","chn","]",",","'image_name_location","'",":","[","n_samples",",","7","]","}","where","the","7-element","location","vector","encode","the","image_id",",","starting","and","ending","coordinates","of","the","image","window",".","Following","the","same","notation",",","the","dictionary","can","be","extended","to","multiple","modalities",";","the","keys","will","be",":",":","{","'image_name_1","'",",","'image_name_1_location","'",",","'image_name_2","'",",","'image_name_2_location","'",",","...","}",":","param","idx",":","image_id","used","to","load","the","image","at","the","i-th","row","of","the","input",":","return",":","a","image","data","dictionary"]
code: def layer_op(self, idx=None):
      """
      Generating each image as a window.
      Overriding this function to create new image sampling strategies.
  
      This function should either yield or return a dictionary
      (of multiple windows per image)::
  
          return a dictionary:
          {
           'image_name': a numpy array [n_samples, h, w, d, chn],
           'image_name_location': [n_samples, 7]
          }
  
      where the 7-element location vector encode the image_id,
      starting and ending coordinates of the image window.
  
      Following the same notation, the dictionary can be extended
      to multiple modalities; the keys will be::
  
          {'image_name_1', 'image_name_1_location',
           'image_name_2', 'image_name_2_location', ...}
  
      :param idx: image_id used to load the image at the i-th row of
          the input
      :return: a image data dictionary
      """
      image_id, image_data, _ = self.reader(idx=idx)
      for mod in list(image_data):
          spatial_shape = image_data[mod].shape[:N_SPATIAL]
          coords = self.dummy_coordinates(image_id, spatial_shape, 1)
          image_data[LOCATION_FORMAT.format(mod)] = coords
          image_data[mod] = image_data[mod][np.newaxis, ...]
      return image_data
  
imports: from __future__ import absolute_import, division, print_function
  import inspect
  import numpy
  import tensorflow
  from tensorflow.python.data.util import nest
  from tensorflow.python.keras.utils import GeneratorEnqueuer
  from niftynet.engine.image_window import ImageWindow, N_SPATIAL, LOCATION_FORMAT, BUFFER_POSITION_NP_TYPE
  from niftynet.io.misc_io import squeeze_spatial_temporal_dim
  from niftynet.layer.base_layer import Layer
  from niftynet.utilities.util_common import look_up_operations
label_desc: Use image node_id 6 for calling the ImageWindowDataset obj's underlying member method code with example usage: obj.layer_op(idx) and returns: image_data