code: def to_numpy(
      x: Union[torch.Tensor, List[torch.Tensor]],
      /,
      *,
      copy: bool = True,
  ) -> Union[np.ndarray, List[np.ndarray]]:
      if isinstance(x, (float, int, bool)):
          return x
      elif isinstance(x, np.ndarray):
          if copy:
              return x.copy()
          else:
              return x
      elif torch.is_tensor(x):
          x = x.resolve_neg().resolve_conj()
          if copy:
              # we don't use inbuilt numpy() because it blocks for
              # bfloat16, which we are supporting here by importing
              # ml_dtypes
              # TODO: use torch's numpy() method once this feature is accepted
              # https://github.com/pytorch/pytorch/issues/109873
              if 0 in x.shape:
                  # this is necessary because tolist converts all empty shapes to (0,)
                  return np.empty(
                      x.shape, dtype=ivy.as_ivy_dtype(x.dtype)
                  )
              return np.array(
                  x.tolist(), dtype=ivy.as_ivy_dtype(x.dtype)
              )
          else:
              raise ivy.utils.exceptions.IvyException(
                  "Overwriting the same address is not supported for torch."
              )
      elif isinstance(x, list):
          return [ivy.to_numpy(u) for u in x]
      raise ivy.utils.exceptions.IvyException(
          "Expected a pytorch tensor."
      )
  
imports: from functools import reduce
  from numbers import Number
  from operator import mul
  from typing import Optional, Union, Sequence, Callable, List, Tuple
  import numpy
  import torch
  import ivy
  from ivy.func_wrapper import with_unsupported_dtypes, _update_torch_views
  from .None import backend_version, is_variable
  from ...ivy.general import _broadcast_to
label_desc: Use image node_id 9 for calling a global function with example usage: to_numpy() and returns: x, x, x, np, unknown, np