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: This function maps a dataset of integers to a dataset of images.
  
  :return: a `tf.data.Dataset`
docstr_tok: ["This","function","maps","a","dataset","of","integers","to","a","dataset","of","images",".",":","return",":","a","`","tf.data.Dataset","`"]
code: def _dataset_from_range(self):
      """
      This function maps a dataset of integers to a dataset of images.
  
      :return: a `tf.data.Dataset`
      """
      # dataset: a list of integers
      tf.logging.info(
          "Initialising Dataset from %s subjects...", self.n_subjects
      )
      dataset = tf.data.Dataset.range(self.n_subjects)
      if self.shuffle:
          # global shuffle of the entire set of subjects
          dataset = dataset.shuffle(
              buffer_size=self.n_subjects, seed=self._seed
          )
  
      # dataset: map each integer i to n windows sampled from subject i
      def _tf_wrapper(idx):
          flattened_types = nest.flatten(self.tf_dtypes)
          flattened_shapes = nest.flatten(self.tf_shapes)
          flat_values = tf.py_func(
              func=lambda subject_id: nest.flatten(self(subject_id)),
              inp=[idx],
              Tout=flattened_types,
          )
          for ret_t, shape in zip(flat_values, flattened_shapes):
              # the actual returned numpy array shapes are not checked
              ret_t.set_shape(shape)
          return nest.pack_sequence_as(self.tf_dtypes, flat_values)
  
      dataset = dataset.map(
          _tf_wrapper, num_parallel_calls=self._num_threads
      )
  
      # dataset: slice the n-element window into n single windows
      dataset = dataset.flat_map(
          map_func=tf.data.Dataset.from_tensor_slices
      )
      return dataset
  
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 10 for calling the ImageWindowDataset obj's underlying member method code with example usage: obj._dataset_from_range() and returns: dataset, nest