code: def to_numpy(
      x: Union[torch.Tensor, np.ndarray, Any, None]
  ) -> Union[np.ndarray, None]:
      """
      Convert whatever to numpy array. None value returned as is.
  
      Args:
          :param x: List, tuple, PyTorch tensor or numpy array
  
      Returns:
          :return: Numpy array
      """
      if x is None:
          return None
      elif torch.is_tensor(x):
          return x.data.cpu().numpy()
      elif isinstance(x, np.ndarray):
          return x
      elif isinstance(x, (Iterable, int, float)):
          return np.array(x)
      else:
          raise ValueError("Unsupported type")
  
imports: import collections
  import dataclasses
  import functools
  import warnings
  import logging
  from typing import Optional, Sequence, Union, Dict, List, Any, Iterable, Callable
  import numpy
  import torch
  from torch import nn, Tensor
  from torch.utils.data import Dataset, ConcatDataset
  from torch.utils.data.dataloader import default_collate
  from .support import pytorch_toolbelt_deprecated
label_desc: Use image node_id 13 for calling a global function with example usage: to_numpy(x) and returns: None, x, x, np