code: def _get_dimension(shape, dim, min_rank=1):
      """Returns the `dim` dimension of `shape`, while checking it has `min_rank`.
  
      Args:
        shape: A `TensorShape`.
        dim: Integer, which dimension to return.
        min_rank: Integer, minimum rank of shape.
  
      Returns:
        The value of the `dim` dimension.
  
      Raises:
        ValueError: if inputs don't have at least min_rank dimensions, or if the
          first dimension value is not defined.
      """
      dims = shape.dims
      if dims is None:
          raise ValueError("dims of shape must be known but is None")
      if len(dims) < min_rank:
          raise ValueError(
              "rank of shape must be at least %d not: %d"
              % (min_rank, len(dims))
          )
      value = dims[dim].value
      if value is None:
          raise ValueError(
              "dimension %d of shape must be known but is None: %s"
              % (dim, shape)
          )
      return value
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from collections import namedtuple
  from collections import OrderedDict
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import variables
label_desc: Use image node_id 10 for calling a global function with example usage: _get_dimension(shape, dim, min_rank) and returns: value