code: def format_customized_shapes(args, shapes):
      if isinstance(args, (list, tuple)):
          if not isinstance(shapes, list) or len(args) != len(shapes):
              raise ValueError(
                  "Customized shapes cannot fit for input list"
              )
          for i, (arg, shape) in enumerate(zip(args, shapes)):
              if len(arg.shape) != len(shape):
                  raise ValueError(
                      "Index-{} shape length must be same as input".format(
                          i
                      )
                  )
          return shapes
      elif isinstance(args, dict):
          if not isinstance(shapes, (list, dict)) or len(args) != len(
              shapes
          ):
              raise ValueError(
                  "Customized shapes cannot fit for input dict"
              )
          if isinstance(shapes, list):
              shapes = {k: v for k, v in zip(args.keys(), shapes)}
          formatted_shapes = []
          for k, arg in args.items():
              if k not in shapes:
                  raise ValueError(
                      'Key "{}" is not found in customized shapes'.format(
                          k
                      )
                  )
              if len(arg.shape) != len(shapes[k]):
                  raise ValueError(
                      'Key "{}" shape length must be same as input'.format(
                          k
                      )
                  )
              formatted_shapes.append(shapes[k])
          return formatted_shapes
      else:
          assert isinstance(
              args, (chainer.Variable, chainer.get_array_types())
          )
          if isinstance(shapes, list):
              if len(shapes) != 1:
                  raise ValueError("Customized shape must be single")
          elif not isinstance(shapes, tuple):
              raise ValueError(
                  "Type {} is not supported for single input".format(
                      type(shapes)
                  )
              )
          else:
              shapes = [shapes]
          if len(args.shape) != len(shapes[0]):
              raise ValueError("Shape length must be same as input")
          return shapes
  
file_path: chainer/onnx_chainer/export.py
imports: from __future__ import print_function
  from collections import OrderedDict
  import warnings
  import chainer
label_desc: Use image node_id 4 for calling a global function with example usage: format_customized_shapes(args, shapes) and returns: shapes, formatted_shapes, shapes