def get_batch_size(tensor, dynamic=False):
    ' Return batch size (the length of the first dimension) of the input tensor.\n\n    Parameters\n    ----------\n    tensor : tf.Tensor\n\n    Returns\n    -------\n    batch size : int or None\n    '
    if dynamic:
        return tf.shape(tensor)[0]
    return tensor.get_shape().as_list()[0]
Return batch size (the length of the first dimension) of the input tensor.

Parameters
----------
tensor : tf.Tensor

Returns
-------
batch size : int or None
def get_batch_size(tensor, dynamic=False):
    ' Return batch size (the length of the first dimension) of the input tensor.\n\n    Parameters\n    ----------\n    tensor : tf.Tensor\n\n    Returns\n    -------\n    batch size : int or None\n    '
    if dynamic:
        return tf.shape(tensor)[0]
    return tensor.get_shape().as_list()[0]