code: def _calc_out_shape(shape, axis, keepdims):
      if axis is None:
          axis = list(range(len(shape)))
      elif isinstance(axis, int):
          axis = [axis]
      else:
          axis = list(axis)
  
      shape = numpy.array(shape)
  
      if keepdims:
          shape[axis] = 1
      else:
          shape[axis] = -1
          shape = filter(lambda x: x != -1, shape)
      return tuple(shape)
  
imports: import warnings
  import numpy
  from cupy import testing
label_desc: Use image node_id 1 for calling a global function with example usage: _calc_out_shape(shape, axis, keepdims) and returns: tuple