code: def _cook_nd_args(a, s=None, axes=None, invreal=False):
      """Similar to :func:`numpy.fft.fftpack._cook_nd_args`."""
  
      if axes is None:
          if s is None:
              len_s = len(a.shape)
          else:
              len_s = len(s)
  
          axes = list(range(-len_s, 0))
  
      if s is None:
          s = list(numpy.take(a.shape, axes))
  
          if invreal:
              s[-1] = (a.shape[axes[-1]] - 1) * 2
  
      if len(s) != len(axes):
          raise ValueError(
              "Shape error: " "Shape and axes have different lengths."
          )
  
      if len(s) > len(a.shape):
          raise ValueError(
              "Shape error: "
              "The length of s or axes cannot exceed the dimensionality "
              "of the input array, a."
          )
  
      return tuple(s), tuple(axes)
  
file_path: py-fftw/pyfftw/builders/_utils.py
imports: import multiprocessing
  import pyfftw
  import numpy
  import warnings
  from ..None import _threading_type
  from ..None import config
label_desc: Use image node_id 8 for calling a global function with example usage: _cook_nd_args(a, s, axes, invreal) and returns: tuple,  tuple