code: def average(
      a, /, *, axis=None, weights=None, returned=False, keepdims=False
  ):
      axis = tuple(axis) if isinstance(axis, list) else axis
      avg = 0
  
      if keepdims is None:
          keepdims_kw = {}
      else:
          keepdims_kw = {"keepdims": keepdims}
  
      dtype = a.dtype
      if weights is None:
          avg = a.mean(axis, **keepdims_kw)
          weights_sum = avg.dtype.type(a.count(axis))
      else:
          if a.shape != weights.shape:
              if axis is None:
                  return 0
              weights = ivy.broadcast_to(
                  weights, (a.ndim - 1) * (1,) + weights.shape
              )
              weights = weights.swapaxes(-1, axis)
          weights_sum = weights.sum(axis=axis, **keepdims_kw)
          mul = ivy.multiply(a, weights)
          avg = ivy.sum(mul, axis=axis, **keepdims_kw) / weights_sum
  
      if returned:
          if weights_sum.shape != avg.shape:
              weights_sum = ivy.broadcast_to(
                  weights_sum, avg.shape
              ).copy()
          return avg.astype(dtype), weights_sum
      else:
          return avg.astype(dtype)
  
file_path: ivy/ivy/functional/frontends/numpy/statistics/averages_and_variances.py
imports: import ivy
  from ivy.func_wrapper import with_unsupported_dtypes
  from ivy.functional.frontends.numpy.func_wrapper import to_ivy_arrays_and_back, handle_numpy_dtype, from_zero_dim_arrays_to_scalar, handle_numpy_out
label_desc: Use image node_id 1 for calling a global function with example usage: average() and returns: avg,  weights_sum, avg, int