o
    ?ey                     @   s4   d Z ddlZddlmZ dd Zdd Zdd	 ZdS )
z$A library of common shape functions.    N)tensor_shapec                 C   s   t ttjt | jt |jtdd}g }|D ][\}}|jdu s'|jdu rM|jdur7|jdkr7|| q|jdurG|jdkrG|| q|d q|jdkrX|| q|jdkrc|| q|j|jkrr||	| q dS |S )a  Helper functions for is_broadcast_compatible and broadcast_shape.

  Args:
    shape_x: A `TensorShape`
    shape_y: A `TensorShape`

  Returns:
    Returns None if the shapes are not broadcast compatible,
    a list of the broadcast dimensions otherwise.
     )	fillvalueN)
reversedlist	itertoolszip_longestdimsr   Z	DimensionvalueappendZ
merge_with)shape_xshape_yZbroadcasted_dimsreturn_dimsZdim_xZdim_y r   j/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/framework/common_shapes.py_broadcast_shape_helper   s2   

r   c                 C   s&   | j du s
|j du rdS t| |duS )zReturns True if `shape_x` and `shape_y` are broadcast compatible.

  Args:
    shape_x: A `TensorShape`
    shape_y: A `TensorShape`

  Returns:
    True if a shape exists that both `shape_x` and `shape_y` can be broadcasted
    to.  False otherwise.
  NF)ndimsr   )r   r   r   r   r   is_broadcast_compatibleG   s   r   c                 C   sN   | j du s
|j du rt S t| |}|du r"td|  d| dt|S )a  Returns the broadcasted shape between `shape_x` and `shape_y`.

  Args:
    shape_x: A `TensorShape`
    shape_y: A `TensorShape`

  Returns:
    A `TensorShape` representing the broadcasted shape.

  Raises:
    ValueError: If the two shapes can not be broadcasted.
  NzIncompatible shapes for broadcasting. Two shapes are compatible if for each dimension pair they are either equal or one of them is 1. Received: z and .)r   r   Zunknown_shaper   
ValueErrorZTensorShape)r   r   r   r   r   r   broadcast_shapeW   s   


r   )__doc__r   Ztensorflow.python.frameworkr   r   r   r   r   r   r   r   <module>   s   2