class_docstr: Visualizer for supervised image datasets.
class_docstr_tok: ["Visualizer","for","supervised","image","datasets","."]
docstr: Display the dataset.
  
  Args:
    ds: `tf.data.Dataset`. The tf.data.Dataset object to visualize. Examples
      should not be batched. Examples will be consumed in order until (rows *
      cols) are read or the dataset is consumed.
    ds_info: `tfds.core.DatasetInfo` object of the dataset to visualize.
    rows: `int`, number of rows of the display grid.
    cols: `int`, number of columns of the display grid.
    plot_scale: `float`, controls the plot size of the images. Keep this value
      around 3 to get a good plot. High and low values may cause the labels to
      get overlapped.
    image_key: `string`, name of the feature that contains the image. If not
      set, the system will try to auto-detect it.
    label_key: `string`, name of the feature that contains the label. If not
      set, the system will try to auto-detect it.
  
  Returns:
    fig: The pyplot figure.
docstr_tok: ["Display","the","dataset",".","Args",":","ds",":","`","tf.data.Dataset","`",".","The","tf.data.Dataset","object","to","visualize",".","Examples","should","not","be","batched",".","Examples","will","be","consumed","in","order","until","(","rows","*","cols",")","are","read","or","the","dataset","is","consumed",".","ds_info",":","`","tfds.core.DatasetInfo","`","object","of","the","dataset","to","visualize",".","rows",":","`","int","`",",","number","of","rows","of","the","display","grid",".","cols",":","`","int","`",",","number","of","columns","of","the","display","grid",".","plot_scale",":","`","float","`",",","controls","the","plot","size","of","the","images",".","Keep","this","value","around","3","to","get","a","good","plot",".","High","and","low","values","may","cause","the","labels","to","get","overlapped",".","image_key",":","`","string","`",",","name","of","the","feature","that","contains","the","image",".","If","not","set",",","the","system","will","try","to","auto-detect","it",".","label_key",":","`","string","`",",","name","of","the","feature","that","contains","the","label",".","If","not","set",",","the","system","will","try","to","auto-detect","it",".","Returns",":","fig",":","The","pyplot","figure","."]
code: def show(
      self,
      ds: tf.data.Dataset,
      ds_info: dataset_info.DatasetInfo,
      rows: int = 3,
      cols: int = 3,
      plot_scale: float = 3.0,
      image_key: Optional[str] = None,
      label_key: Optional[str] = None,
  ):
      """Display the dataset.
  
      Args:
        ds: `tf.data.Dataset`. The tf.data.Dataset object to visualize. Examples
          should not be batched. Examples will be consumed in order until (rows *
          cols) are read or the dataset is consumed.
        ds_info: `tfds.core.DatasetInfo` object of the dataset to visualize.
        rows: `int`, number of rows of the display grid.
        cols: `int`, number of columns of the display grid.
        plot_scale: `float`, controls the plot size of the images. Keep this value
          around 3 to get a good plot. High and low values may cause the labels to
          get overlapped.
        image_key: `string`, name of the feature that contains the image. If not
          set, the system will try to auto-detect it.
        label_key: `string`, name of the feature that contains the label. If not
          set, the system will try to auto-detect it.
  
      Returns:
        fig: The pyplot figure.
      """
      # Extract the image key
      if not image_key:
          image_keys = visualizer.extract_keys(
              ds_info.features, features_lib.Image
          )
          if len(image_keys) > 1:
              raise ValueError(
                  "Multiple image features detected in the dataset. "
                  "Use `image_key` argument to override. Images detected: {}".format(
                      image_keys
                  )
              )
          image_key = image_keys[0]
  
      # Optionally extract the label key
      label_keys = visualizer.extract_keys(
          ds_info.features, features_lib.ClassLabel
      )
      if label_key is not None:
          assert (
              label_key in label_keys
          ), f'Label "{label_key}" not found: {label_keys}.'
      else:
          label_key = label_keys[0] if len(label_keys) == 1 else None
          if not label_key:
              logging.info("Was not able to auto-infer label.")
  
      # Single image display
      def make_cell_fn(ax, ex):
          plt = lazy_imports_lib.lazy_imports.matplotlib.pyplot
  
          if not isinstance(ex, dict):
              raise ValueError(
                  "{} requires examples as `dict`, with the same "
                  "structure as `ds_info.features`. It is currently not compatible "
                  "with `as_supervised=True`. Received: {}".format(
                      type(self).__name__, type(ex)
                  )
              )
  
          _add_image(ax, ex[image_key])
          if label_key:
              label = ex[label_key]
              label_str = ds_info.features[label_key].int2str(label)
              plt.xlabel("{} ({})".format(label_str, label))
  
      # Returns the grid.
      fig = _make_grid(make_cell_fn, ds, rows, cols, plot_scale)
      return fig
  
file_path: datasets/tensorflow_datasets/core/visualization/image_visualizer.py
imports: from __future__ import annotations
  from typing import Optional
  from absl import logging
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import dataset_utils
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  from tensorflow_datasets.core.visualization import visualizer
label_desc: Use image node_id 2 for calling the ImageGridVisualizer obj's underlying member method code with example usage: obj.show(ds, ds_info, rows, cols, plot_scale, image_key, label_key) and returns: fig