code: def shape_list(tensor: Union[tf.Tensor, np.ndarray]) -> List[int]:
      """
      Deal with dynamic shape in tensorflow cleanly.
  
      Args:
          tensor (`tf.Tensor` or `np.ndarray`): The tensor we want the shape of.
  
      Returns:
          `List[int]`: The shape of the tensor as a list.
      """
      if isinstance(tensor, np.ndarray):
          return list(tensor.shape)
  
      dynamic = tf.shape(tensor)
  
      if tensor.shape == tf.TensorShape(None):
          return dynamic
  
      static = tensor.shape.as_list()
  
      return [
          dynamic[i] if s is None else s for i, s in enumerate(static)
      ]
  
file_path: transformers/src/transformers/tf_utils.py
imports: from typing import List, Optional, Union
  import numpy
  import tensorflow
  from .utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: shape_list(tensor) and returns: unknown, list, dynamic