code: def nll_loss(
      input,
      target,
      weight=None,
      size_average=None,
      ignore_index=-100,
      reduce=None,
      reduction="mean",
  ):
      out = ivy.zeros_like(target)
  
      if len(input.shape) == 1:
          for i in range(len(target)):
              out[i] = input[target[i]]
      else:
          for i in range(len(target)):
              out[i] = input[i][target[i]]
      loss = -out
  
      if weight is not None:
          loss = ivy.multiply(weight, loss)
      reduct = _get_reduction(reduction, size_average, reduce)
      ret = reduct(loss)
  
      return ret
  
imports: import ivy
  import ivy.functional.frontends.torch
  from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
label_desc: Use image node_id 20 for calling a global function with example usage: nll_loss(input, target, weight, size_average, ignore_index, reduce, reduction) and returns: ret