code: def to_list(x: torch.Tensor, /) -> list:
      if isinstance(x, np.ndarray):
          return x.tolist()
      elif torch.is_tensor(x):
          if x.dtype is torch.bfloat16:
              default_dtype = ivy.default_float_dtype(as_native=True)
              if default_dtype is torch.bfloat16:
                  x = x.to(torch.float32)
              else:
                  x = x.to(default_dtype)
              return (
                  x.detach().cpu().numpy().astype("bfloat16").tolist()
              )
          else:
              return x.detach().cpu().numpy().tolist()
      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 11 for calling a global function with example usage: to_list() and returns: x, x, x