class_docstr: Process and show the image batch and its associated label using matplotlib.
code: def _to_numpy(img: Union[Tensor, Image.Image]) -> np.ndarray:
      out: np.ndarray
      if isinstance(img, np.ndarray):
          out = img
      elif isinstance(img, Image.Image):
          out = np.array(img)
      elif isinstance(img, Tensor):
          out = img.squeeze(0).permute(1, 2, 0).cpu().numpy()
      else:
          raise TypeError(f"Unknown image type. Got: {type(img)}.")
      return out
  
file_path: lightning-flash/src/flash/image/segmentation/viz.py
imports: from typing import Any, Dict, List, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from flash.core.data.base_viz import BaseVisualization
  from flash.core.data.io.input import DataKeys
  from flash.core.utilities.imports import _MATPLOTLIB_AVAILABLE, Image, requires
  from flash.core.utilities.stages import RunningStage
  from flash.image.segmentation.output import SegmentationLabelsOutput
label_desc: Use image node_id 2 for calling the SegmentationMatplotlibVisualization obj's underlying member method code with example usage: obj._to_numpy(img) and returns: out