code: def inv(
      x: torch.Tensor,
      /,
      *,
      adjoint: bool = False,
      out: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      if adjoint:
          if x.dim() < 2:
              raise ValueError("Input must be at least 2D")
          x_adj = x.transpose(-2, -1).conj()
          ret = torch.linalg.inv(x_adj)
      else:
          ret = torch.linalg.inv(x)
  
      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 8 for calling a global function with example usage: inv() and returns: ret, ivy