code: def assert_dynamic_shapes(
      onnx_program: torch.onnx.ONNXProgram, dynamic_shapes: bool
  ):
      """Assert whether the exported model has dynamic shapes or not.
  
      Args:
          onnx_program (torch.onnx.ONNXProgram): The output of torch.onnx.dynamo_export.
          dynamic_shapes (bool): Whether the exported model has dynamic shapes or not.
              When True, raises if graph inputs don't have at least one dynamic dimension
              When False, raises if graph inputs have at least one dynamic dimension.
  
      Raises:
          AssertionError: If the exported model has dynamic shapes and dynamic_shapes is False and vice-versa.
      """
  
      if dynamic_shapes is None:
          return
  
      model_proto = onnx_program.model_proto
      # Process graph inputs
      dynamic_inputs = []
      for inp in model_proto.graph.input:
          dynamic_inputs += [
              dim
              for dim in inp.type.tensor_type.shape.dim
              if dim.dim_value == 0 and dim.dim_param != ""
          ]
      assert dynamic_shapes == (
          len(dynamic_inputs) > 0
      ), "Dynamic shape check failed for graph inputs"
  
imports: from __future__ import annotations
  import contextlib
  import copy
  import dataclasses
  import io
  import logging
  import os
  import unittest
  import warnings
  from typing import Any, Callable, Collection, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union
  import numpy
  import onnxruntime
  import pytest
  import pytorch_test_common
  import torch
  from torch import export
  from torch.onnx import _constants, verification
  from torch.onnx._internal import _beartype
  from torch.onnx._internal.fx import diagnostics
  from torch.testing._internal import common_utils
  from torch.testing._internal.opinfo import core
  from torch.types import Number
label_desc: Use image node_id 2 for calling a global function with example usage: assert_dynamic_shapes(onnx_program, dynamic_shapes) without return types