class_docstr: ```
  Main class used to tune and train Keras models
  using a Keras generator (e.g., DirectoryIterator).
  Objects of this class should be instantiated using the
  ktrain.get_learner function, rather than directly.
  
  Main parameters are:
  
  model (Model): A compiled instance of keras.engine.training.Model
  train_data (Iterator): a Iterator instance for training set
  val_data (Iterator):   A Iterator instance for validation set
  ```
class_docstr_tok: ["``","`","Main","class","used","to","tune","and","train","Keras","models","using","a","Keras","generator","(","e.g.",",","DirectoryIterator",")",".","Objects","of","this","class","should","be","instantiated","using","the","ktrain.get_learner","function",",","rather","than","directly",".","Main","parameters","are",":","model","(","Model",")",":","A","compiled","instance","of","keras.engine.training.Model","train_data","(","Iterator",")",":","a","Iterator","instance","for","training","set","val_data","(","Iterator",")",":","A","Iterator","instance","for","validation","set","``","`"]
docstr: ```
  Views observations with top losses in validation set.
  Typically over-ridden by Learner subclasses.
  Args:
   n(int or tuple): a range to select in form of int or tuple
                    e.g., n=8 is treated as n=(0,8)
   preproc (Preprocessor): A TextPreprocessor or ImagePreprocessor.
                           For some data like text data, a preprocessor
                           is required to undo the pre-processing
                           to correctly view raw data.
    val_data:  optional val_data to use instead of self.val_data
  Returns:
      list of n tuples where first element is either
      filepath or id of validation example and second element
      is loss.
  ```
docstr_tok: ["``","`","Views","observations","with","top","losses","in","validation","set",".","Typically","over-ridden","by","Learner","subclasses",".","Args",":","n","(","int","or","tuple",")",":","a","range","to","select","in","form","of","int","or","tuple","e.g.",",","n=8","is","treated","as","n=","(","0,8",")","preproc","(","Preprocessor",")",":","A","TextPreprocessor","or","ImagePreprocessor",".","For","some","data","like","text","data",",","a","preprocessor","is","required","to","undo","the","pre-processing","to","correctly","view","raw","data",".","val_data",":","optional","val_data","to","use","instead","of","self.val_data","Returns",":","list","of","n","tuples","where","first","element","is","either","filepath","or","id","of","validation","example","and","second","element","is","loss",".","``","`"]
code: def view_top_losses(self, n=4, preproc=None, val_data=None):
      """
      ```
      Views observations with top losses in validation set.
      Typically over-ridden by Learner subclasses.
      Args:
       n(int or tuple): a range to select in form of int or tuple
                        e.g., n=8 is treated as n=(0,8)
       preproc (Preprocessor): A TextPreprocessor or ImagePreprocessor.
                               For some data like text data, a preprocessor
                               is required to undo the pre-processing
                               to correctly view raw data.
        val_data:  optional val_data to use instead of self.val_data
      Returns:
          list of n tuples where first element is either
          filepath or id of validation example and second element
          is loss.
      ```
      """
      val = self._check_val(val_data)
  
      # get top losses and associated data
      tups = self.top_losses(n=n, val_data=val, preproc=preproc)
  
      # get multilabel status and class names
      classes = preproc.get_classes() if preproc is not None else None
      # iterate through losses
      for tup in tups:
          # get data
          idx = tup[0]
          loss = tup[1]
          truth = tup[2]
          pred = tup[3]
  
          print("----------")
          print(
              "id:%s | loss:%s | true:%s | pred:%s)\n"
              % (idx, round(loss, 2), truth, pred)
          )
      return
  
imports: from .None import utils
  from .graph.predictor import LinkPredictor, NodePredictor
  from .graph.preprocessor import LinkPreprocessor, NodePreprocessor
  from .imports import *
  from .lroptimize.lrfinder import *
  from .tabular.predictor import TabularPredictor
  from .tabular.preprocessor import TabularPreprocessor
  from .text.ner.predictor import NERPredictor
  from .text.ner.preprocessor import NERPreprocessor
  from .text.predictor import TextPredictor
  from .text.preprocessor import BERTPreprocessor, TextPreprocessor, TransformersPreprocessor
  from .vision.predictor import ImagePredictor
  from .vision.preprocessor import ImagePreprocessor
label_desc: Use image node_id 4 for calling the GenLearner obj's underlying member method code with example usage: obj.view_top_losses(n, preproc, val_data) without return types