code: def test_symbol_infer_shape():
      num_hidden = 128
      num_dim = 64
      num_sample = 10
  
      data = mx.symbol.Variable("data")
      prev = mx.symbol.Variable("prevstate")
      x2h = mx.symbol.FullyConnected(
          data=data, name="x2h", num_hidden=num_hidden
      )
      h2h = mx.symbol.FullyConnected(
          data=prev, name="h2h", num_hidden=num_hidden
      )
  
      out = mx.symbol.Activation(
          data=mx.sym.elemwise_add(x2h, h2h),
          name="out",
          act_type="relu",
      )
  
      # shape inference will fail because information is not available for h2h
      ret = out.infer_shape(data=(num_sample, num_dim))
      assert ret == (None, None, None)
  
      arg, out_shapes, aux_shapes = out.infer_shape_partial(
          data=(num_sample, num_dim)
      )
      arg_shapes = dict(zip(out.list_arguments(), arg))
      assert arg_shapes["data"] == (num_sample, num_dim)
      assert arg_shapes["x2h_weight"] == (num_hidden, num_dim)
      assert arg_shapes["h2h_weight"] == ()
  
      # now we can do full shape inference
      state_shape = out_shapes[0]
      arg, out_shapes, aux_shapes = out.infer_shape(
          data=(num_sample, num_dim), prevstate=state_shape
      )
      arg_shapes = dict(zip(out.list_arguments(), arg))
      assert arg_shapes["data"] == (num_sample, num_dim)
      assert arg_shapes["x2h_weight"] == (num_hidden, num_dim)
      assert arg_shapes["h2h_weight"] == (num_hidden, num_hidden)
  
      # Partial shape inference with some unknown dimensions
      data_shape = (1, 0, 0, 0)
      data = mx.sym.Variable("data", shape=data_shape)
      weight = mx.sym.Variable("weight")
      cdata = mx.sym.cast(data, dtype="float16")
      cweight = mx.sym.cast(weight, dtype="float16")
      test = mx.sym.Convolution(
          data=cdata,
          weight=cweight,
          pad=(3, 3),
          num_filter=64,
          stride=(2, 2),
          no_bias=True,
          kernel=(7, 7),
      )
  
      arg, _, _ = test.infer_shape_partial()
      arg_shapes = dict(zip(test.list_arguments(), arg))
      assert arg_shapes["data"] == data_shape
      assert arg_shapes["weight"] == (64, 0, 7, 7)
  
imports: import copy
  import sys
  import os
  import logging
  import re
  import json
  import mxnet
  import numpy
  from common import assertRaises, models, TemporaryDirectory
  from mxnet.base import NotImplementedForSymbol
  from mxnet.test_utils import discard_stderr, rand_shape_nd, use_np, environment
  from mxnet.util import np_shape
  import pickle
label_desc: Use image node_id 9 for calling a global function with example usage: test_symbol_infer_shape() without return types