code: def nonzero(
      x: torch.Tensor,
      /,
      *,
      as_tuple: bool = True,
      size: Optional[int] = None,
      fill_value: Number = 0,
  ) -> Union[torch.Tensor, Tuple[torch.Tensor]]:
      res = torch.stack(torch.nonzero(x, as_tuple=True))
  
      if size is not None:
          if isinstance(fill_value, float):
              res = res.to(dtype=torch.float64)
  
          diff = size - res[0].shape[0]
          if diff > 0:
              res = tnf.pad(res, (0, diff), value=fill_value)
          elif diff < 0:
              res = res[:, :size]
  
      res = tuple(res)
      if as_tuple:
          return res
      return torch.stack(res, dim=1)
  
file_path: ivy/ivy/functional/backends/torch/searching.py
imports: from numbers import Number
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn.functional
  import ivy
  from ivy.func_wrapper import with_unsupported_dtypes
  from .None import backend_version
label_desc: Use image node_id 3 for calling a global function with example usage: nonzero() and returns: torch, res