code: def as_array(
      x: Union[Tensoray, Tuple[Tensoray, ...]]
  ) -> Union[np.ndarray, Tuple[np.ndarray, ...]]:
      """Convert every item in a tuple of tensors/arrays into an array.
  
      Args:
          x: A tensor, array, or a tuple of potentially mixed tensors and arrays.
  
      Returns:
          x, with everything converted to array.
      """
      if isinstance(x, tuple):
          return tuple(as_array(x_i) for x_i in x)  # pyre-ignore
      elif isinstance(x, np.ndarray):
          return x
      elif torch.is_tensor(x):
          return x.detach().cpu().double().numpy()
      else:
          raise ValueError(
              "Input to as_array must be numpy array or torch tensor"
          )
  
imports: from __future__ import annotations
  import itertools
  import warnings
  from typing import Callable, Dict, List, Optional, Protocol, Set, Tuple, Union
  import numpy
  import torch
  from ax.core.search_space import SearchSpaceDigest
  from ax.exceptions.core import SearchSpaceExhausted, UnsupportedError
  from ax.models.types import TConfig
  from ax.utils.common.typeutils import checked_cast
  from botorch.acquisition.risk_measures import RiskMeasureMCObjective
  from torch import Tensor
label_desc: Use image node_id 9 for calling a global function with example usage: as_array(x) and returns: tuple, x, x