code: def to_numpy(
      X: Optional[Union[List, np.ndarray, tf.Tensor]]
  ) -> Optional[Union[List, np.ndarray]]:
      """
      Converts given tensor to `numpy` array.
  
      Parameters
      ----------
      X
          Input tensor to be converted to `numpy` array.
  
      Returns
      -------
      `Numpy` representation of the input tensor.
      """
      if X is not None:
          if isinstance(X, np.ndarray):
              return X
  
          if isinstance(X, tf.Tensor):
              return X.numpy()
  
          if isinstance(X, list):
              return [to_numpy(e) for e in X]
  
          return np.array(X)
      return None
  
imports: import os
  import random
  from typing import Any, List, Dict, Callable, Union, Optional, TYPE_CHECKING
  import numpy
  import tensorflow
  import tensorflow.keras
  from alibi.explainers.backends.cfrl_base import CounterfactualRLDataset
  from alibi.models.tensorflow.actor_critic import Actor, Critic
label_desc: Use image node_id 15 for calling a global function with example usage: to_numpy(X) and returns: None, np, X, X, unknown