code: def cholesky(
      x: torch.Tensor,
      /,
      *,
      upper: bool = False,
      out: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      if not upper:
          return torch.linalg.cholesky(x, out=out)
      else:
          ret = torch.transpose(
              torch.linalg.cholesky(
                  torch.transpose(
                      x, dim0=len(x.shape) - 1, dim1=len(x.shape) - 2
                  )
              ),
              dim0=len(x.shape) - 1,
              dim1=len(x.shape) - 2,
          )
          if ivy.exists(out):
              return ivy.inplace_update(out, ret)
          return ret
  
imports: import torch
  from typing import Union, Optional, Tuple, Literal, List, NamedTuple, Sequence
  from collections import namedtuple
  import ivy
  from ivy import inf
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from .None import backend_version
  from .elementwise import _cast_for_unary_op
label_desc: Use image node_id 1 for calling a global function with example usage: cholesky() and returns: torch, ret, ivy