class_docstr: Convert Tensor into Numpy Array.
docstr: Convert Tensor into Numpy Array.
  
  Args:
     tensor (Tensor): Tensor to convert. Input tensor in range 0-1.
     dims (tuple[int, ...] | None, optional): Convert dimensions from torch to numpy format.
          Tuple corresponding to axis permutation from torch tensor to numpy array. Defaults to None.
  
  Returns:
      Converted numpy ndarray.
code: def __call__(
      self, tensor: Tensor, dims: tuple[int, ...] | None = None
  ) -> np.ndarray:
      """Convert Tensor into Numpy Array.
  
      Args:
         tensor (Tensor): Tensor to convert. Input tensor in range 0-1.
         dims (tuple[int, ...] | None, optional): Convert dimensions from torch to numpy format.
              Tuple corresponding to axis permutation from torch tensor to numpy array. Defaults to None.
  
      Returns:
          Converted numpy ndarray.
      """
      # Default support is (C, H, W) or (N, C, H, W)
      if dims is None:
          dims = (0, 2, 3, 1) if len(tensor.shape) == 4 else (1, 2, 0)
  
      array = (
          (tensor * 255).permute(dims).cpu().numpy().astype(np.uint8)
      )
  
      if array.shape[0] == 1:
          array = array.squeeze(0)
      if array.shape[-1] == 1:
          array = array.squeeze(-1)
  
      return array
  
file_path: anomalib/src/anomalib/pre_processing/transforms/custom.py
imports: from __future__ import annotations
  import warnings
  import numpy
  import torch
  from torch import Tensor
label_desc: Use image node_id 1 for calling the ToNumpy obj's underlying member method code with example usage: obj.__call__(tensor, dims) and returns: array