o
    2h                     @   sP   d Z ddlmZ ddlmZ ddlmZ ddlmZ dejfddZdd	 Zd
S )zHelpers constructing Datasets.    )constant_op)dtypes)ops)tensor_shapec                 C   s(   |d urt j||| dS tj||| dS )N)dtypename)r   convert_to_tensorr   constant)argument_nameargument_valueargument_defaultargument_dtype r   ^/var/www/html/chatgem/venv/lib/python3.10/site-packages/tensorflow/python/data/util/convert.pyoptional_param_to_tensor   s   r   c              	   C   s   zt | } tjdd |  D tjdW S  ttfyQ   tj| tjd}|j	j
dur=t|j	j
dkr=td| |j	|jtjkrMtd| |jj| Y S w )	a/  Returns a `tf.Tensor` that represents the given shape.

  Args:
    shape_like: A value that can be converted to a `tf.TensorShape` or a
      `tf.Tensor`.

  Returns:
    A 1-D `tf.Tensor` of `tf.int64` elements representing the given shape, where
    `-1` is substituted for any unknown dimensions.
  c                 S   s   g | ]
}|d ur
|ndqS )Nr   ).0dimr   r   r   
<listcomp>3   s    z+partial_shape_to_tensor.<locals>.<listcomp>)r   )preferred_dtypeN   zSThe given shape {} must be a 1-D tensor of `tf.int64` values, but the shape was {}.zZThe given shape {} must be a 1-D tensor of `tf.int64` values, but the element type was {}.)r   as_shaper   r   as_listr   int64	TypeError
ValueErrorshapedimslenformatr   r   )
shape_likeretr   r   r   partial_shape_to_tensor"   s,   
r"   N)	__doc__tensorflow.python.frameworkr   r   r   r   r   r   r"   r   r   r   r   <module>   s   
