docstr: Get shape from tensor_type or sparse_tensor_type according to given name
docstr_tok: ["Get","shape","from","tensor_type","or","sparse_tensor_type","according","to","given","name"]
code: def _get_shape_from_name(
      self, onnx_model: ModelProto, name: str
  ) -> Optional[TensorShapeProto]:
      """Get shape from tensor_type or sparse_tensor_type according to given name"""
      inputs = list(onnx_model.graph.input)
      outputs = list(onnx_model.graph.output)
      valueinfos = list(onnx_model.graph.value_info)
      for v in inputs + outputs + valueinfos:
          if v.name == name:
              if v.type.HasField("tensor_type"):
                  return v.type.tensor_type.shape  # type: ignore
              if v.type.HasField("sparse_tensor_type"):
                  return v.type.sparse_tensor_type.shape  # type: ignore
      return None
  
file_path: onnx/onnx/test/symbolic_shape_test.py
imports: import unittest
  from typing import List, Optional
  import onnx.shape_inference
  from onnx import ModelProto, TensorProto, TensorShapeProto, ValueInfoProto, helper
  from onnx.helper import make_model, make_tensor_value_info
label_desc: Use image node_id 3 for calling the TestSymbolicShape obj's underlying member method code with example usage: obj._get_shape_from_name(onnx_model, name) and returns: None, v, v