code: def _get_output(output, input, shape=None, complex_output=False):
      if shape is None:
          shape = input.shape
      if output is None:
          if not complex_output:
              output = numpy.zeros(shape, dtype=input.dtype.name)
          else:
              complex_type = numpy.promote_types(
                  input.dtype, numpy.complex64
              )
              output = numpy.zeros(shape, dtype=complex_type)
      elif isinstance(output, (type, numpy.dtype)):
          # Classes (like `np.float32`) and dtypes are interpreted as dtype
          if complex_output and numpy.dtype(output).kind != "c":
              warnings.warn(
                  "promoting specified output dtype to complex",
                  stacklevel=3,
              )
              output = numpy.promote_types(output, numpy.complex64)
          output = numpy.zeros(shape, dtype=output)
      elif isinstance(output, str):
          # testsuite only appears to cover
          # f->np.float32 here
          f_dict = {
              "f": numpy.float32,
              "d": numpy.float64,
              "F": numpy.complex64,
              "D": numpy.complex128,
          }
          output = f_dict[output]
          if complex_output and numpy.dtype(output).kind != "c":
              raise RuntimeError("output must have complex dtype")
          output = numpy.zeros(shape, dtype=output)
      elif output.shape != shape:
          raise RuntimeError("output shape not correct")
      elif complex_output and output.dtype.kind != "c":
          raise RuntimeError("output must have complex dtype")
      return output
  
file_path: scipy/scipy/ndimage/_ni_support.py
imports: from collections.abc import Iterable
  import operator
  import warnings
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: _get_output(output, input, shape, complex_output) and returns: output