a
    .SicN	                    @   s  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ejZ ej!Z"ej#Z$edddgde%ddddZ&edgde'dddddZ(ed gde'dd!dd$d%Z)ed&gde'dd'dd(d)Z*ed*gde'dd+dd,d-Z+ed.gde'dd/dd0d1Z,d2d3 Z-G d4d5 d5e.Z/d6d7 Z0d8d9 Z1d:d; Z2dd<d=Z3d>d? Z4d@dA Z5dBdC Z6dDdE Z7dFdG Z8dHdI Z9dJdK Z:dLdM Z;dNdO Z<dPdQ Z=dRdS Z>dTdU Z?ddXdYZ@ddZd[ZAdd\d]ZBdd^d_ZCed`gde'ddaddbdcZDeddgde'ddeddfdgZEedhgde'ddiddjdkZFedlgde'ddmddndoZGedpgde'ddqddrdsZHedtgde'dduddvdwZIedxgde'ddyddzd{ZJed|gde'dd}dd~dZKdS )zzInput pipeline.

Please see the [reading data
how-to](https://tensorflow.org/api_guides/python/reading_data)
for context.
    )context)constant_op)dtypes)ops)sparse_tensor)tensor_shape)utils)	array_ops)control_flow_ops)data_flow_ops)io_ops)math_ops)
random_ops)
sparse_ops)variable_scope)summary)queue_runner)deprecation)collections_abc)	tf_exportzio.match_filenames_onceztrain.match_filenames_once)v1Nc                 C   sT   t |d| g0}tj|t| ddt jjgdW  d   S 1 sF0    Y  dS )a\  Save the list of files matching pattern, so it is only computed once.

  NOTE: The order of the files returned is deterministic.

  Args:
    pattern: A file pattern (glob), or 1D tensor of file patterns.
    name: A name for the operations (optional).

  Returns:
    A variable that is initialized to the list of files matching the pattern(s).
  Zmatching_filenamesF)nameinitial_value	trainablevalidate_shapecollectionsN)r   
name_scopevsvariabler   matching_files	GraphKeysLOCAL_VARIABLES)patternr    r#   \/var/www/html/django/DPS/env/lib/python3.9/site-packages/tensorflow/python/training/input.pymatch_filenames_once5   s    
r%   ztrain.limit_epochsz{Queue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.from_tensors(tensor).repeat(num_epochs)`.c              	   C   s   |du r| S |dkr t d| t|d| g}tjdtjd}tj|ddtj	j
gd}||}t|g, tj| |d	W  d   W  d   S 1 s0    Y  W d   n1 s0    Y  dS )
a  Returns tensor `num_epochs` times and then raises an `OutOfRange` error.

  Note: creates local counter `epochs`. Use `local_variables_initializer()` to
  initialize local variables.

  Args:
    tensor: Any `Tensor`.
    num_epochs: A positive integer (optional).  If specified, limits the number
      of steps the output tensor may be evaluated.
    name: A name for the operations (optional).

  Returns:
    tensor or `OutOfRange`.

  Raises:
    ValueError: if `num_epochs` is invalid.
  Nr   znum_epochs must be > 0 not %d.limit_epochsdtypeepochsF)r   r   r   r   )
ValueErrorr   r   r   constantr   int64r   r   r    r!   count_up_tocontrol_dependenciesr	   identity)tensor
num_epochsr   Zzero64r)   counterr#   r#   r$   r&   L   s    
r&   ztrain.input_producerzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.from_tensor_slices(input_tensor).shuffle(tf.shape(input_tensor, out_type=tf.int64)[0]).repeat(num_epochs)`. If `shuffle=False`, omit the `.shuffle(...)`.T    c
                 C   s  t  rtdt|d| g tj| dd} | jdd |}| sTt	d|rft
j| |d} t| |} tj|| jjg|g||d	}
|
| g}ttj|
|g|	d
 |durt|t|
 tjd|   |
W  d   S 1  s0    Y  dS )a  Output the rows of `input_tensor` to a queue for an input pipeline.

  Note: if `num_epochs` is not `None`, this function creates local counter
  `epochs`. Use `local_variables_initializer()` to initialize local variables.

  Args:
    input_tensor: A tensor with the rows to produce. Must be at least
      one-dimensional. Must either have a fully-defined shape, or
      `element_shape` must be defined.
    element_shape: (Optional.) A `TensorShape` representing the shape of a
      row of `input_tensor`, if it cannot be inferred.
    num_epochs: (Optional.) An integer. If specified `input_producer` produces
      each row of `input_tensor` `num_epochs` times before generating an
      `OutOfRange` error. If not specified, `input_producer` can cycle through
      the rows of `input_tensor` an unlimited number of times.
    shuffle: (Optional.) A boolean. If true, the rows are randomly shuffled
      within each epoch.
    seed: (Optional.) An integer. The seed to use if `shuffle` is true.
    capacity: (Optional.) The capacity of the queue to be used for buffering
      the input.
    shared_name: (Optional.) If set, this queue will be shared under the given
      name across multiple sessions.
    summary_name: (Optional.) If set, a scalar summary for the current queue
      size will be generated, using this name as part of the tag.
    name: (Optional.) A name for queue.
    cancel_op: (Optional.) Cancel op for the queue

  Returns:
    A queue with the output rows.  A `QueueRunner` for the queue is
    added to the current `QUEUE_RUNNER` collection of the current
    graph.

  Raises:
    ValueError: If the shape of the input cannot be inferred from the arguments.
    RuntimeError: If called with eager execution enabled.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  Input pipelines based on Queues are not supported when eager execution is enabled. Please use tf.data to ingest data into your model instead.input_producerinput_tensorr*      NzZEither `input_tensor` must have a fully defined shape or `element_shape` must be specified)seed)capacityr   shapesshared_namer   )	cancel_op      ?)r   executing_eagerlyRuntimeErrorr   r   convert_to_tensorshape
merge_withis_fully_definedr+   r   random_shuffler&   r   	FIFOQueuer(   
base_dtypeenqueue_manyr   add_queue_runnerQueueRunnerr   scalarr   castsizer   float32)r7   element_shaper2   shuffler9   r:   r<   summary_namer   r=   qZenqr#   r#   r$   r6   p   s8    9
r6   ztrain.string_input_producerzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.from_tensor_slices(string_tensor).shuffle(tf.shape(input_tensor, out_type=tf.int64)[0]).repeat(num_epochs)`. If `shuffle=False`, omit the `.shuffle(...)`.c           	      C   s   d}t | tjs| st|t|d| g}tj| tjd} tt	
tt| d|gg t| } W d   n1 s0    Y  t| g ||||||d| |d
W  d   S 1 s0    Y  dS )a  Output strings (e.g. filenames) to a queue for an input pipeline.

  Note: if `num_epochs` is not `None`, this function creates local counter
  `epochs`. Use `local_variables_initializer()` to initialize local variables.

  Args:
    string_tensor: A 1-D string tensor with the strings to produce.
    num_epochs: An integer (optional). If specified, `string_input_producer`
      produces each string from `string_tensor` `num_epochs` times before
      generating an `OutOfRange` error. If not specified,
      `string_input_producer` can cycle through the strings in `string_tensor`
      an unlimited number of times.
    shuffle: Boolean. If true, the strings are randomly shuffled within each
      epoch.
    seed: An integer (optional). Seed used if shuffle == True.
    capacity: An integer. Sets the queue capacity.
    shared_name: (optional). If set, this queue will be shared under the given
      name across multiple sessions. All sessions open to the device which has
      this queue will be able to access it via the shared_name. Using this in
      a distributed setting means each name will only be seen by one of the
      sessions which has access to this operation.
    name: A name for the operations (optional).
    cancel_op: Cancel op for the queue (optional).

  Returns:
    A queue with the output strings.  A `QueueRunner` for the Queue
    is added to the current `Graph`'s `QUEUE_RUNNER` collection.

  Raises:
    ValueError: If the string_tensor is a null Python list.  At runtime,
    will fail with an assertion if string_tensor becomes a null tensor.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  z6string_input_producer requires a non-null input tensorr6   r'   r   Nfraction_of_%d_full)
r7   rO   r2   rP   r9   r:   r<   r   rQ   r=   )
isinstancer   Tensorr+   r   rA   r   stringr/   r
   Assertr   greaterr	   rM   r0   r6   )	string_tensorr2   rP   r9   r:   r<   r   r=   Znot_null_errr#   r#   r$   string_input_producer   s0    3(rZ   ztrain.range_input_producerzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.range(limit).shuffle(limit).repeat(num_epochs)`. If `shuffle=False`, omit the `.shuffle(...)`.c                 C   sZ   t |d| g6}t| }t|g |||||d| |	W  d   S 1 sL0    Y  dS )a  Produces the integers from 0 to limit-1 in a queue.

  Note: if `num_epochs` is not `None`, this function creates local counter
  `epochs`. Use `local_variables_initializer()` to initialize local variables.

  Args:
    limit: An int32 scalar tensor.
    num_epochs: An integer (optional). If specified, `range_input_producer`
      produces each integer `num_epochs` times before generating an
      OutOfRange error. If not specified, `range_input_producer` can cycle
      through the integers an unlimited number of times.
    shuffle: Boolean. If true, the integers are randomly shuffled within each
      epoch.
    seed: An integer (optional). Seed used if shuffle == True.
    capacity: An integer. Sets the queue capacity.
    shared_name: (optional). If set, this queue will be shared under the given
      name across multiple sessions.
    name: A name for the operations (optional).

  Returns:
    A Queue with the output integers.  A `QueueRunner` for the Queue
    is added to the current `Graph`'s `QUEUE_RUNNER` collection.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  r6   rS   N)r   r   r   ranger6   )limitr2   rP   r9   r:   r<   r   Zrange_tensorr#   r#   r$   range_input_producer  s    #

r]   ztrain.slice_input_producerzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.from_tensor_slices(tuple(tensor_list)).shuffle(tf.shape(input_tensor, out_type=tf.int64)[0]).repeat(num_epochs)`. If `shuffle=False`, omit the `.shuffle(...)`.c           
   	      s   t |d| j t | } | s&tdt| d d }t||||||d}|   fdd| D }	|	W  d   S 1 s~0    Y  dS )a  Produces a slice of each `Tensor` in `tensor_list`.

  Implemented using a Queue -- a `QueueRunner` for the Queue
  is added to the current `Graph`'s `QUEUE_RUNNER` collection.

  Args:
    tensor_list: A list of `Tensor` objects. Every `Tensor` in
      `tensor_list` must have the same size in the first dimension.
    num_epochs: An integer (optional). If specified, `slice_input_producer`
      produces each slice `num_epochs` times before generating
      an `OutOfRange` error. If not specified, `slice_input_producer` can cycle
      through the slices an unlimited number of times.
    shuffle: Boolean. If true, the integers are randomly shuffled within each
      epoch.
    seed: An integer (optional). Seed used if shuffle == True.
    capacity: An integer. Sets the queue capacity.
    shared_name: (optional). If set, this queue will be shared under the given
      name across multiple sessions.
    name: A name for the operations (optional).

  Returns:
    A list of tensors, one for each element of `tensor_list`.  If the tensor
    in `tensor_list` has shape `[N, a, b, .., z]`, then the corresponding output
    tensor will have shape `[a, b, ..., z]`.

  Raises:
    ValueError: if `slice_input_producer` produces nothing from `tensor_list`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  r6   z7Expected at least one tensor in slice_input_producer().r   )r2   rP   r9   r:   r<   c                    s   g | ]}t | qS r#   )r	   gather.0tindexr#   r$   
<listcomp>r      z(slice_input_producer.<locals>.<listcomp>N)r   r   %convert_n_to_tensor_or_indexed_slicesr+   r	   rB   r]   dequeue)
tensor_listr2   rP   r9   r:   r<   r   Z
range_sizequeueoutputr#   rb   r$   slice_input_producer=  s    )
rk   c                 C   s   dd | D S )Nc                 S   s   g | ]}|D ]}|qqS r#   r#   )r`   rh   r1   r#   r#   r$   rd   z  re   z_flatten.<locals>.<listcomp>r#   tensor_list_listr#   r#   r$   _flatteny  s    rn   c                   @   s\   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Ze	dd Z
e	dd Ze	dd ZdS )_SparseMetaDatazDStore information about the Tensor: Is it sparse?, map_op, and rank.c                 C   s   || _ || _t|| _dS )a?  Create the metadata.

    Args:
      sparse: Python boolean.
      map_op: The `Operation` that created the `SparseTensorsMap` in question.
        This Op contains information about the underlying Map object and the
        dtype of the original data.
      rank: The statically known rank of the `SparseTensor`.
    N)_sparse_map_opr   as_dimension_rank)selfsparsemap_oprankr#   r#   r$   __init__  s    
z_SparseMetaData.__init__c                 C   sX   | j |j krdS | j sdS | jd u|jd ukr2dS | j|jkrBdS | j|jsTdS dS )NFT)ru   rv   rw   is_compatible_withrt   otherr#   r#   r$   __eq__  s    z_SparseMetaData.__eq__c                 C   s   |  | S N)r|   rz   r#   r#   r$   __ne__  s    z_SparseMetaData.__ne__c                 C   s   d| j | jj| jf S )Nz[SparseMetaData(%s, %s, %s)])ru   rv   r   rw   rt   r#   r#   r$   __str__  s    z_SparseMetaData.__str__c                 C   s0   | |krt d| |f | jr,| j|j | S )Nz2SparseMetaData objects are incompatible: %s vs. %s)r+   ru   rw   rC   rz   r#   r#   r$   rC     s    z_SparseMetaData.merge_withc                 C   s   | j S r}   )rq   r   r#   r#   r$   rv     s    z_SparseMetaData.map_opc                 C   s   | j S r}   )rp   r   r#   r#   r$   ru     s    z_SparseMetaData.sparsec                 C   s   | j S r}   )rs   r   r#   r#   r$   rw     s    z_SparseMetaData.rankN)__name__
__module____qualname____doc__rx   r|   r~   r   rC   propertyrv   ru   rw   r#   r#   r#   r$   ro   }  s   

ro   c                    s,   t  tr$ fddt tdD S  S d S )Nc                    s   g | ]} | qS r#   r#   )r`   ktensorsr#   r$   rd     re   z#_as_tensor_list.<locals>.<listcomp>key)rT   dictsortedstrr   r#   r   r$   _as_tensor_list  s    
r   c                 C   sj   | st dt| d trbt| d  }| dd  D ]}t| |kr6t dq6dd | D S | S d S )Nz$Expected at least one set of tensorsr   r8   z8All dictionaries in tensors_list must have the same keysc                 S   s   g | ]}t |qS r#   )r   )r`   r   r#   r#   r$   rd     re   z(_as_tensor_list_list.<locals>.<listcomp>)r+   rT   r   setkeys)tensors_listexpected_keysr   r#   r#   r$   _as_tensor_list_list  s    
r   c                    sB   t | tr:t| dkr g  fddtt| tdD S  S d S )Nr8   c                    s   i | ]\}}| | qS r#   r#   )r`   ir   rh   r#   r$   
<dictcomp>  s   z%_as_original_type.<locals>.<dictcomp>r   )rT   r   len	enumerater   r   )original_tensorsrh   r#   r   r$   _as_original_type  s    

r   c                    s   |pdgt |  }fddfdd  fddt| |D }dd	 fd
dt| ||D }dd t||D }||fS )a  Store SparseTensors for feeding into batch, etc.

  If `shared_map_ops` is provided, the underlying `SparseTensorsMap` objects
  are reused (shared).  This argument is useful for, e.g., `batch_join`
  where multiple enqueue operations write to the same Queue component,
  and another (dequeue) thread reads from that same location and must then
  restore the associated `SparseTensor` objects.  In this case, the sparse
  restore must have a single `SparseTensorMap` from which to read out the
  handles; so a single `SparseTensorMap` must be shared for storing
  across the multiple enqueue operations.  This sharing is performed by
  calling `_store_sparse_tensors` the first time with `shared_map_ops=None`,
  and then in subsequent times with this value set to the list of `Operation`
  objects created in the first call.

  Args:
    tensor_list: List of `Tensor` and `SparseTensor` objects.
    enqueue_many: Python `Boolean`.
    keep_input: Must be a scalar bool Tensor (not a Python bool). If False,
      don't store.
    shared_map_ops: (optional) List of `Operation` objects from a previous
      call to `_store_sparse_tensors`.  If not `None`, the op types should be
      one of `AddSparseToTensorsMap` or `AddManySparseToTensorsMap` in the
      locations corresponding to `SparseTensors` in `tensor_list`.

  Returns:
    A tuple `(stored_list, sparse_info_list)` where `stored_list` is a list
    of `Tensor` objects (same length as `tensor_list`) and `sparse_info_list`
    is a list of the same length of `_SparseMetaData` objects.
  Nc                    sJ   t | tjstdd d S | jjdjd } r8|d8 }td|pB||dS )NFr8   r   T)ru   rv   rw   )rT   r   SparseTensorro   dense_shaperB   	with_rankdims)ra   Z
storing_oprv   rw   )rH   r#   r$   _sparse_meta_data  s    
z0_store_sparse_tensors.<locals>._sparse_meta_datac                    sx   t | tjs| S |r|jnd}dd }dd }dd }jjdkr^t| || } d	d
 }n rh|}n|}|| |S )z"Store Sparse tensor, if necessary.Nc                    s   t | fdddd S )z+Conditionally store a single sparse Tensor.c                      s   t  dS N)r<   )_store_sparser#   map_op_namera   r#   r$   <lambda>  re   zZ_store_sparse_tensors.<locals>._maybe_store.<locals>._maybe_store_sparse.<locals>.<lambda>c                   S   s   t dtjS )N)r   r,   r   r-   r#   r#   r#   r$   r     re   )r   
smart_cond)ra   r   
keep_inputr#   r   r$   _maybe_store_sparse
  s
    zH_store_sparse_tensors.<locals>._maybe_store.<locals>._maybe_store_sparsec                    s0   t | fddfdd}|dg |S )z,Conditionally store multiple sparse Tensors.c                      s   t  dS r   _store_many_sparser#   r   r#   r$   r     re   z__store_sparse_tensors.<locals>._maybe_store.<locals>._maybe_store_many_sparse.<locals>.<lambda>c                      s    dt t  dd tj S )Nr   r   r8   )r	   onesrB   r   r-   r#   )ra   r#   r$   r     re   N)r   r   	set_shape)ra   r   r   
out_tensorr#   r   r$   _maybe_store_many_sparse  s    
zM_store_sparse_tensors.<locals>._maybe_store.<locals>._maybe_store_many_sparsec                 S   s   | j dddf }t||S )z9Convert a per-row `keep_input` vector to a per-value one.Nr   )indicesr	   r^   )ra   r   
row_valuesr#   r#   r$   _sparse_values_to_keep  s    zK_store_sparse_tensors.<locals>._maybe_store.<locals>._sparse_values_to_keepr8   c                 S   s   t | |dS r   r   )ra   r   _r#   r#   r$   r      re   z=_store_sparse_tensors.<locals>._maybe_store.<locals>.<lambda>)rT   r   r   r   rB   ndimsr   sparse_retain)ra   shared_map_opr   r   r   r   Zstore_f)rH   r   r#   r$   _maybe_store  s    
z+_store_sparse_tensors.<locals>._maybe_storec                    s   g | ]\}} ||qS r#   r#   )r`   ra   r   )r   r#   r$   rd   '  s   z)_store_sparse_tensors.<locals>.<listcomp>c                 S   s*   | j jD ]}|j jdv r|j   S q| j S )N)AddSparseToTensorsMapAddManySparseToTensorsMap)opinputstype)storedr7   r#   r#   r$   
_sparse_op,  s    z)_store_sparse_tensors.<locals>._sparse_opc                    s"   g | ]\}}} |||qS r#   r#   )r`   ra   r   r   )r   r   r#   r$   rd   4  s   c                 S   s(   g | ] \}}|j r t|d gn|qS )r   )ru   r	   expand_dims)r`   sZs_infor#   r#   r$   rd   9  s   )r   zip)rh   rH   r   Zshared_map_opsZmaybe_shared_map_opsstored_listsparse_info_listr#   )r   r   r   rH   r   r$   _store_sparse_tensors  s    "

r   c           	      C   s   t | d ||\}}|g}| dd D ]Z}t |||dd |D \}}||krbtd| d |f dd t||D }|| q&||fS )z5Store SparseTensors for feeding into batch_join, etc.r   r8   Nc                 S   s   g | ]
}|j qS r#   )rv   )r`   str#   r#   r$   rd   G  re   z._store_sparse_tensors_join.<locals>.<listcomp>z*Inconsistent SparseTensors list: %s vs. %sc                 S   s   g | ]\}}| |qS r#   )rC   )r`   info	candidater#   r#   r$   rd   K  s   )r   r+   r   append)	rm   rH   r   s0r   Zstored_list_listrh   r   Zsparse_info_candidater#   r#   r$   _store_sparse_tensors_join?  s$    

r   c                    s   t | tj}|s| f} dd t| |D }tdd |D }|rndd |D   fddfdd|D }n|}|rz|S |d	 S )
z>Restore SparseTensors after dequeue in batch, batch_join, etc.c              	   S   s@   g | ]8\}}|j r8t|jt|d gt|jd  dn|qS )r8   )sparse_map_opsparse_handlesrw   )ru   _restore_sparserv   r	   squeezer   dimension_valuerw   )r`   r   r   r#   r#   r$   rd   X  s   z+_restore_sparse_tensors.<locals>.<listcomp>c                 s   s   | ]}t |tjV  qd S r}   )rT   r   r   r`   xr#   r#   r$   	<genexpr>^  re   z*_restore_sparse_tensors.<locals>.<genexpr>c                 S   s"   g | ]}t |tjr|jn|qS r#   )rT   r   r   valuesr   r#   r#   r$   rd   `  s   c                    s   t  | S r}   )r
   with_dependencies)r   )t_valuesr#   r$   r   d  re   z)_restore_sparse_tensors.<locals>.<lambda>c                    sB   g | ]:}t |tjr6tj |j |j |jd n |qS ))r   r   r   )rT   r   r   r   r   r   r   )	with_depsr#   r$   rd   e  s   
r   )rT   r   Sequencer   any)r   r   Zreceived_sequencer   Zhas_stZensure_restore_tensorsr#   )r   r   r$   _restore_sparse_tensorsS  s"    
r   c                 C   s   t | } | std| S )Nz(Expected at least one tensor in batch().)r   rf   r+   r   r#   r#   r$   	_validateq  s    
r   c                 C   s   dd | D } | st d| S )Nc                 S   s   g | ]}t |qS r#   )r   rf   r`   tlr#   r#   r$   rd   y  s   z"_validate_join.<locals>.<listcomp>z,Expected at least one input in batch_join().)r+   rl   r#   r#   r$   _validate_joinx  s    r   c                 C   sN   t | } | jjdu rtd|s6| jjdkr6td| jjdkrJtd| S )zAValidate `keep_input` argument to conditional batching functions.Nz<`keep_input` dimensions must be known at graph construction.r8   z:`keep_input` cannot be a vector when `enqueue_many=False`.z'`keep_input` must be 0 or 1 dimensions.)r   rA   rB   r   r+   )r   rH   r#   r#   r$   _validate_keep_input  s    
r   c                 C   sd   dd | D }|d }|dd  D ]<}||kr"t dddd |D dd	d |D f q"|S )
Nc                 S   s   g | ]}d d |D qS )c                 S   s   g | ]
}|j qS r#   r'   r_   r#   r#   r$   rd     re   z&_dtypes.<locals>.<listcomp>.<listcomp>r#   r   r#   r#   r$   rd     re   z_dtypes.<locals>.<listcomp>r   r8   z+Expected types to be consistent: %s vs. %s.z, c                 s   s   | ]}|j V  qd S r}   r*   r   r#   r#   r$   r     re   z_dtypes.<locals>.<genexpr>c                 s   s   | ]}|j V  qd S r}   r*   r   r#   r#   r$   r     re   )	TypeErrorjoin)rm   	all_typestypesZother_typesr#   r#   r$   _dtypes  s    r   c                 C   sL   dd | D } |r dd | D } | d }| dd  D ]}| | q4| S )Nc                 S   s   g | ]}t |qS r#   )r   as_shaper`   r   r#   r#   r$   rd     re   z!_merge_shapes.<locals>.<listcomp>c                 S   s   g | ]}| d d d qS )r8   N)with_rank_at_leastr   r#   r#   r$   rd     re   r   r8   )rC   as_list)
shape_listrH   Zmerged_shaper   r#   r#   r$   _merge_shapes  s    r   c                    sh   |du rdt d }D ]2}t|D ]$}|| jjdu r$td||  q$q fddt|D }|S )a  Calculate and merge the shapes of incoming tensors.

  Args:
    tensor_list_list: List of tensor lists.
    shapes: List of shape tuples corresponding to tensors within the lists.
    enqueue_many: Boolean describing whether shapes will be enqueued as
      batches or individual entries.

  Returns:
    A list of shapes aggregating shape inference info from `tensor_list_list`,
    or returning `shapes` if it is not `None`.

  Raises:
    ValueError: If any of the inferred shapes in `tensor_list_list` lack a
      well defined rank.
  Nr   zCannot infer Tensor's rank: %sc                    s$   g | ] t  fd dD qS )c                    s   g | ]}|  j  qS r#   )rB   r   r   r   r#   r$   rd     s   z&_shapes.<locals>.<listcomp>.<listcomp>)r   r`   rH   rm   r   r$   rd     s   z_shapes.<locals>.<listcomp>)r   r[   rB   r   r+   )rm   r;   rH   Zlen0r   r   r#   r   r$   _shapes  s    r   c                    s$   t |tj  fdd| D } | S )z>Select which examples to enqueue based on vector `keep_input`.c                    s    g | ]}t j| d dd qS )   )num_partitionsr8   )r   dynamic_partitionr   Zselect_ir#   r$   rd     s   z,_select_which_to_enqueue.<locals>.<listcomp>)r   rL   r   int32)rh   r   r#   r   r$   _select_which_to_enqueue  s
    
r   c                    s^   |r| j  n| j jjdkr4 fdd|D }n fdd|D }tt| | dS )z&Enqueue `tensor_list_list` in `queue`.r8   c                    s   g | ]} t |qS r#   )r   r   
enqueue_fnr   r#   r$   rd     s   z!_enqueue_join.<locals>.<listcomp>c                    s&   g | ] t  fd dtjqS )c                      s    S r}   r#   r#   )r   r   r#   r$   r     re   z*_enqueue_join.<locals>.<listcomp>.<lambda>)r   r   r
   no_opr   r   )r   r$   rd     s   N)rH   enqueuerB   r   r   rI   rJ   )ri   rm   rH   r   enqueue_opsr#   r   r$   _enqueue_join  s    r   c                    sj   |r| j  n| j |jjdkr4 t|g| }n t| fddtjg| }t	
t	| | dS )z!Enqueue `tensor_list` in `queue`.r8   c                      s    S r}   r#   r#   r   rh   r#   r$   r     re   z_enqueue.<locals>.<lambda>N)rH   r   rB   r   r   r   r   r
   r   r   rI   rJ   )ri   rh   threadsrH   r   r   r#   r   r$   _enqueue  s     r   c                 C   s   | r
t jS t jS r}   )r   PaddingFIFOQueuerF   )dynamic_padr#   r#   r$   _which_queue  s    
r   r8   Fc                 C   s  t  rtdt| }t|
dt||g }
t|}t||}t	|||\}}t
|g}t|g||}t|||||	d}t||||| td| t| tjd|   |r|j||
d}n|j||
d}t||}t| |W  d   S 1 s0    Y  dS )z.Helper function for `batch` and `maybe_batch`.r5   batchr:   r   r;   r<   rS   r>   r*   N)r   r?   r+   r   r   r   listr   r   r   r   r   r   r   r   rK   r   rL   rM   r   rN   dequeue_up_todequeue_manyr   r   )r   
batch_sizer   num_threadsr:   rH   r;   r   allow_smaller_final_batchr<   r   rh   sparse_infor   ri   dequeuedr#   r#   r$   _batch  s4    


r	  c
                 C   s  t  rtdt| }
t|	dt|
|g }	t|
}
t||}t	|
||\}
}t
|
}t|
||}t|||||d}t||
|| td| t| tjd|   |r|j||	d}n|j||	d}t||}t| d |W  d   S 1 s 0    Y  dS )	z8Helper function for `batch_join` and `maybe_batch_join`.r5   
batch_joinr   rS   r>   r*   r   N)r   r?   r+   r   r   r   rn   r   r   r   r   r   r   r   r   rK   r   rL   rM   r   rN   r  r  r   r   )r   r  r   r:   rH   r;   r   r  r<   r   rm   r  r   ri   r  r#   r#   r$   _batch_join  s:    

r  c              	   C   sN  t  rtdt| }t|dt||g }||krLtd||f t|}t||}t	|||\}}t
|g}t|g||}tj||||||
d}t||||| ttd| | tjd||   }d||| f }t|| |	r|j||d}n|j||d}t||}t| |W  d	   S 1 s@0    Y  d	S )
z>Helper function for `shuffle_batch` and `maybe_shuffle_batch`.r5   shuffle_batchz5capacity %d must be bigger than min_after_dequeue %d.r:   min_after_dequeuer9   r   r;   r<   r   r>   fraction_over_%d_of_%d_fullr*   N)r   r?   r+   r   r   r   r  r   r   r   r   r   r   RandomShuffleQueuer   r   rL   maximumrM   r   rN   r   rK   r  r  r   r   )r   r  r:   r  r   r  r9   rH   r;   r  r<   r   rh   r  r   ri   fullrQ   r  r#   r#   r$   _shuffle_batch@  sP    




r  c              	   C   s0  t  rtdt| }t|
dt||g }
t|}t||}t	|||\}}t
|}t|||}tj||||||	d}t|||| ttd| | tjd||   }d||| f }t|| |r|j||
d}n|j||
d}t||}t| d |W  d   S 1 s"0    Y  dS )	zHHelper function for `shuffle_batch_join` and `maybe_shuffle_batch_join`.r5   shuffle_batch_joinr  r   r>   r  r*   N)r   r?   r+   r   r   r   rn   r   r   r   r   r   r   r  r   r   rL   r  rM   r   rN   r   rK   r  r  r   r   )r   r  r:   r  r   r9   rH   r;   r  r<   r   rm   r  r   ri   r  rQ   r  r#   r#   r$   _shuffle_batch_joinl  sH    



r  ztrain.batchzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.batch(batch_size)` (or `padded_batch(...)` if `dynamic_pad=True`).c
           
      C   s   t | |d||||||||	dS )aW  Creates batches of tensors in `tensors`.

  The argument `tensors` can be a list or a dictionary of tensors.
  The value returned by the function will be of the same type
  as `tensors`.

  This function is implemented using a queue. A `QueueRunner` for the
  queue is added to the current `Graph`'s `QUEUE_RUNNER` collection.

  If `enqueue_many` is `False`, `tensors` is assumed to represent a single
  example.  An input tensor with shape `[x, y, z]` will be output as a tensor
  with shape `[batch_size, x, y, z]`.

  If `enqueue_many` is `True`, `tensors` is assumed to represent a batch of
  examples, where the first dimension is indexed by example, and all members of
  `tensors` should have the same size in the first dimension.  If an input
  tensor has shape `[*, x, y, z]`, the output will have shape `[batch_size, x,
  y, z]`.  The `capacity` argument controls the how long the prefetching is
  allowed to grow the queues.

  The returned operation is a dequeue operation and will throw
  `tf.errors.OutOfRangeError` if the input queue is exhausted. If this
  operation is feeding another input queue, its queue runner will catch
  this exception, however, if this operation is used in your main thread
  you are responsible for catching this yourself.

  *N.B.:* If `dynamic_pad` is `False`, you must ensure that either
  (i) the `shapes` argument is passed, or (ii) all of the tensors in
  `tensors` must have fully-defined shapes. `ValueError` will be
  raised if neither of these conditions holds.

  If `dynamic_pad` is `True`, it is sufficient that the *rank* of the
  tensors is known, but individual dimensions may have shape `None`.
  In this case, for each enqueue the dimensions with value `None`
  may have a variable length; upon dequeue, the output tensors will be padded
  on the right to the maximum shape of the tensors in the current minibatch.
  For numbers, this padding takes value 0.  For strings, this padding is
  the empty string.  See `PaddingFIFOQueue` for more info.

  If `allow_smaller_final_batch` is `True`, a smaller batch value than
  `batch_size` is returned when the queue is closed and there are not enough
  elements to fill the batch, otherwise the pending elements are discarded.
  In addition, all output tensors' static shapes, as accessed via the
  `shape` property will have a first `Dimension` value of `None`, and
  operations that depend on fixed batch_size would fail.

  Args:
    tensors: The list or dictionary of tensors to enqueue.
    batch_size: The new batch size pulled from the queue.
    num_threads: The number of threads enqueuing `tensors`.  The batching will
      be nondeterministic if `num_threads > 1`.
    capacity: An integer. The maximum number of elements in the queue.
    enqueue_many: Whether each tensor in `tensors` is a single example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensors`.
    dynamic_pad: Boolean.  Allow variable dimensions in input shapes.
      The given dimensions are padded upon dequeue so that tensors within a
      batch have the same shapes.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (Optional). If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the same types as `tensors` (except if
    the input is a list of one element, then it returns a tensor, not a list).

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensors`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  T)	r   r  r:   rH   r;   r   r  r<   r   r	  )
r   r  r  r:   rH   r;   r   r  r<   r   r#   r#   r$   r     s    Ur   ztrain.maybe_batchzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.filter(...).batch(batch_size)` (or `padded_batch(...)` if `dynamic_pad=True`).c                 C   s   t | |||||||||	|
dS )a  Conditionally creates batches of tensors based on `keep_input`.

  See docstring in `batch` for more details.

  Args:
    tensors: The list or dictionary of tensors to enqueue.
    keep_input: A `bool` Tensor.  This tensor controls whether the input is
      added to the queue or not.  If it is a scalar and evaluates `True`, then
      `tensors` are all added to the queue. If it is a vector and `enqueue_many`
      is `True`, then each example is added to the queue only if the
      corresponding value in `keep_input` is `True`. This tensor essentially
      acts as a filtering mechanism.
    batch_size: The new batch size pulled from the queue.
    num_threads: The number of threads enqueuing `tensors`.  The batching will
      be nondeterministic if `num_threads > 1`.
    capacity: An integer. The maximum number of elements in the queue.
    enqueue_many: Whether each tensor in `tensors` is a single example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensors`.
    dynamic_pad: Boolean.  Allow variable dimensions in input shapes.
      The given dimensions are padded upon dequeue so that tensors within a
      batch have the same shapes.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (Optional). If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the same types as `tensors`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensors`.
  )r  r:   rH   r;   r   r  r<   r   r  )r   r   r  r  r:   rH   r;   r   r  r<   r   r#   r#   r$   maybe_batch  s    +r  ztrain.batch_joinzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.interleave(...).batch(batch_size)` (or `padded_batch(...)` if `dynamic_pad=True`).c	           	      C   s   t | |d|||||||d
S )a  Runs a list of tensors to fill a queue to create batches of examples.

  The `tensors_list` argument is a list of tuples of tensors, or a list of
  dictionaries of tensors.  Each element in the list is treated similarly
  to the `tensors` argument of `tf.compat.v1.train.batch()`.

  WARNING: This function is nondeterministic, since it starts a separate thread
  for each tensor.

  Enqueues a different list of tensors in different threads.
  Implemented using a queue -- a `QueueRunner` for the queue
  is added to the current `Graph`'s `QUEUE_RUNNER` collection.

  `len(tensors_list)` threads will be started,
  with thread `i` enqueuing the tensors from
  `tensors_list[i]`. `tensors_list[i1][j]` must match
  `tensors_list[i2][j]` in type and shape, except in the first
  dimension if `enqueue_many` is true.

  If `enqueue_many` is `False`, each `tensors_list[i]` is assumed
  to represent a single example. An input tensor `x` will be output as a
  tensor with shape `[batch_size] + x.shape`.

  If `enqueue_many` is `True`, `tensors_list[i]` is assumed to
  represent a batch of examples, where the first dimension is indexed
  by example, and all members of `tensors_list[i]` should have the
  same size in the first dimension.  The slices of any input tensor
  `x` are treated as examples, and the output tensors will have shape
  `[batch_size] + x.shape[1:]`.

  The `capacity` argument controls the how long the prefetching is allowed to
  grow the queues.

  The returned operation is a dequeue operation and will throw
  `tf.errors.OutOfRangeError` if the input queue is exhausted. If this
  operation is feeding another input queue, its queue runner will catch
  this exception, however, if this operation is used in your main thread
  you are responsible for catching this yourself.

  *N.B.:* If `dynamic_pad` is `False`, you must ensure that either
  (i) the `shapes` argument is passed, or (ii) all of the tensors in
  `tensors_list` must have fully-defined shapes. `ValueError` will be
  raised if neither of these conditions holds.

  If `dynamic_pad` is `True`, it is sufficient that the *rank* of the
  tensors is known, but individual dimensions may have value `None`.
  In this case, for each enqueue the dimensions with value `None`
  may have a variable length; upon dequeue, the output tensors will be padded
  on the right to the maximum shape of the tensors in the current minibatch.
  For numbers, this padding takes value 0.  For strings, this padding is
  the empty string.  See `PaddingFIFOQueue` for more info.

  If `allow_smaller_final_batch` is `True`, a smaller batch value than
  `batch_size` is returned when the queue is closed and there are not enough
  elements to fill the batch, otherwise the pending elements are discarded.
  In addition, all output tensors' static shapes, as accessed via the
  `shape` property will have a first `Dimension` value of `None`, and
  operations that depend on fixed batch_size would fail.

  Args:
    tensors_list: A list of tuples or dictionaries of tensors to enqueue.
    batch_size: An integer. The new batch size pulled from the queue.
    capacity: An integer. The maximum number of elements in the queue.
    enqueue_many: Whether each tensor in `tensor_list_list` is a single
      example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensor_list_list[i]`.
    dynamic_pad: Boolean.  Allow variable dimensions in input shapes.
      The given dimensions are padded upon dequeue so that tensors within a
      batch have the same shapes.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (Optional) If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the same number and types as
    `tensors_list[i]`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensor_list_list`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  T)r   r:   rH   r;   r   r  r<   r   r  )	r   r  r:   rH   r;   r   r  r<   r   r#   r#   r$   r
  5  s    ar
  ztrain.maybe_batch_joinzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.interleave(...).filter(...).batch(batch_size)` (or `padded_batch(...)` if `dynamic_pad=True`).c
           
      C   s   t | |||||||||	d
S )a  Runs a list of tensors to conditionally fill a queue to create batches.

  See docstring in `batch_join` for more details.

  Args:
    tensors_list: A list of tuples or dictionaries of tensors to enqueue.
    keep_input: A `bool` Tensor.  This tensor controls whether the input is
      added to the queue or not.  If it is a scalar and evaluates `True`, then
      `tensors` are all added to the queue. If it is a vector and `enqueue_many`
      is `True`, then each example is added to the queue only if the
      corresponding value in `keep_input` is `True`. This tensor essentially
      acts as a filtering mechanism.
    batch_size: An integer. The new batch size pulled from the queue.
    capacity: An integer. The maximum number of elements in the queue.
    enqueue_many: Whether each tensor in `tensor_list_list` is a single
      example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensor_list_list[i]`.
    dynamic_pad: Boolean.  Allow variable dimensions in input shapes.
      The given dimensions are padded upon dequeue so that tensors within a
      batch have the same shapes.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (Optional) If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the same number and types as
    `tensors_list[i]`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensor_list_list`.
  )r:   rH   r;   r   r  r<   r   r  )
r   r   r  r:   rH   r;   r   r  r<   r   r#   r#   r$   maybe_batch_join  s    ,r  ztrain.shuffle_batchzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.shuffle(min_after_dequeue).batch(batch_size)`.c                 C   s    t | |||d||||||	|
dS )a  Creates batches by randomly shuffling tensors.

  This function adds the following to the current `Graph`:

  * A shuffling queue into which tensors from `tensors` are enqueued.
  * A `dequeue_many` operation to create batches from the queue.
  * A `QueueRunner` to `QUEUE_RUNNER` collection, to enqueue the tensors
    from `tensors`.

  If `enqueue_many` is `False`, `tensors` is assumed to represent a
  single example.  An input tensor with shape `[x, y, z]` will be output
  as a tensor with shape `[batch_size, x, y, z]`.

  If `enqueue_many` is `True`, `tensors` is assumed to represent a
  batch of examples, where the first dimension is indexed by example,
  and all members of `tensors` should have the same size in the
  first dimension.  If an input tensor has shape `[*, x, y, z]`, the
  output will have shape `[batch_size, x, y, z]`.

  The `capacity` argument controls the how long the prefetching is allowed to
  grow the queues.

  The returned operation is a dequeue operation and will throw
  `tf.errors.OutOfRangeError` if the input queue is exhausted. If this
  operation is feeding another input queue, its queue runner will catch
  this exception, however, if this operation is used in your main thread
  you are responsible for catching this yourself.

  For example:

  ```python
  # Creates batches of 32 images and 32 labels.
  image_batch, label_batch = tf.compat.v1.train.shuffle_batch(
        [single_image, single_label],
        batch_size=32,
        num_threads=4,
        capacity=50000,
        min_after_dequeue=10000)
  ```

  *N.B.:* You must ensure that either (i) the `shapes` argument is
  passed, or (ii) all of the tensors in `tensors` must have
  fully-defined shapes. `ValueError` will be raised if neither of
  these conditions holds.

  If `allow_smaller_final_batch` is `True`, a smaller batch value than
  `batch_size` is returned when the queue is closed and there are not enough
  elements to fill the batch, otherwise the pending elements are discarded.
  In addition, all output tensors' static shapes, as accessed via the
  `shape` property will have a first `Dimension` value of `None`, and
  operations that depend on fixed batch_size would fail.

  Args:
    tensors: The list or dictionary of tensors to enqueue.
    batch_size: The new batch size pulled from the queue.
    capacity: An integer. The maximum number of elements in the queue.
    min_after_dequeue: Minimum number elements in the queue after a
      dequeue, used to ensure a level of mixing of elements.
    num_threads: The number of threads enqueuing `tensor_list`.
    seed: Seed for the random shuffling within the queue.
    enqueue_many: Whether each tensor in `tensor_list` is a single example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensor_list`.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (Optional) If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the types as `tensors`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensors`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  T)r   r  r9   rH   r;   r  r<   r   r  )r   r  r:   r  r  r9   rH   r;   r  r<   r   r#   r#   r$   r    s    Xr  ztrain.maybe_shuffle_batchzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.filter(...).shuffle(min_after_dequeue).batch(batch_size)`.c                 C   s    t | |||||||||	|
|dS )ai  Creates batches by randomly shuffling conditionally-enqueued tensors.

  See docstring in `shuffle_batch` for more details.

  Args:
    tensors: The list or dictionary of tensors to enqueue.
    batch_size: The new batch size pulled from the queue.
    capacity: An integer. The maximum number of elements in the queue.
    min_after_dequeue: Minimum number elements in the queue after a
      dequeue, used to ensure a level of mixing of elements.
    keep_input: A `bool` Tensor.  This tensor controls whether the input is
      added to the queue or not.  If it is a scalar and evaluates `True`, then
      `tensors` are all added to the queue. If it is a vector and `enqueue_many`
      is `True`, then each example is added to the queue only if the
      corresponding value in `keep_input` is `True`. This tensor essentially
      acts as a filtering mechanism.
    num_threads: The number of threads enqueuing `tensor_list`.
    seed: Seed for the random shuffling within the queue.
    enqueue_many: Whether each tensor in `tensor_list` is a single example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensor_list`.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (Optional) If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the types as `tensors`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensors`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  )r  r9   rH   r;   r  r<   r   r  )r   r  r:   r  r   r  r9   rH   r;   r  r<   r   r#   r#   r$   maybe_shuffle_batchC  s    1r  ztrain.shuffle_batch_joinzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.interleave(...).shuffle(min_after_dequeue).batch(batch_size)`.c
           
      C   s   t | |||d||||||	dS )a0  Create batches by randomly shuffling tensors.

  The `tensors_list` argument is a list of tuples of tensors, or a list of
  dictionaries of tensors.  Each element in the list is treated similarly
  to the `tensors` argument of `tf.compat.v1.train.shuffle_batch()`.

  This version enqueues a different list of tensors in different threads.
  It adds the following to the current `Graph`:

  * A shuffling queue into which tensors from `tensors_list` are enqueued.
  * A `dequeue_many` operation to create batches from the queue.
  * A `QueueRunner` to `QUEUE_RUNNER` collection, to enqueue the tensors
    from `tensors_list`.

  `len(tensors_list)` threads will be started, with thread `i` enqueuing
  the tensors from `tensors_list[i]`. `tensors_list[i1][j]` must match
  `tensors_list[i2][j]` in type and shape, except in the first dimension if
  `enqueue_many` is true.

  If `enqueue_many` is `False`, each `tensors_list[i]` is assumed
  to represent a single example.  An input tensor with shape `[x, y, z]`
  will be output as a tensor with shape `[batch_size, x, y, z]`.

  If `enqueue_many` is `True`, `tensors_list[i]` is assumed to
  represent a batch of examples, where the first dimension is indexed
  by example, and all members of `tensors_list[i]` should have the
  same size in the first dimension.  If an input tensor has shape `[*, x,
  y, z]`, the output will have shape `[batch_size, x, y, z]`.

  The `capacity` argument controls the how long the prefetching is allowed to
  grow the queues.

  The returned operation is a dequeue operation and will throw
  `tf.errors.OutOfRangeError` if the input queue is exhausted. If this
  operation is feeding another input queue, its queue runner will catch
  this exception, however, if this operation is used in your main thread
  you are responsible for catching this yourself.

  If `allow_smaller_final_batch` is `True`, a smaller batch value than
  `batch_size` is returned when the queue is closed and there are not enough
  elements to fill the batch, otherwise the pending elements are discarded.
  In addition, all output tensors' static shapes, as accessed via the
  `shape` property will have a first `Dimension` value of `None`, and
  operations that depend on fixed batch_size would fail.

  Args:
    tensors_list: A list of tuples or dictionaries of tensors to enqueue.
    batch_size: An integer. The new batch size pulled from the queue.
    capacity: An integer. The maximum number of elements in the queue.
    min_after_dequeue: Minimum number elements in the queue after a
      dequeue, used to ensure a level of mixing of elements.
    seed: Seed for the random shuffling within the queue.
    enqueue_many: Whether each tensor in `tensor_list_list` is a single
      example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensors_list[i]`.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (optional). If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the same number and types as
    `tensors_list[i]`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensors_list`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  T)r   r9   rH   r;   r  r<   r   r  )
r   r  r:   r  r9   rH   r;   r  r<   r   r#   r#   r$   r    s    Tr  ztrain.maybe_shuffle_batch_joinzQueue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.interleave(...).filter(...).shuffle(min_after_dequeue).batch(batch_size)`.c                 C   s   t | |||||||||	|
dS )ay  Create batches by randomly shuffling conditionally-enqueued tensors.

  See docstring in `shuffle_batch_join` for more details.

  Args:
    tensors_list: A list of tuples or dictionaries of tensors to enqueue.
    batch_size: An integer. The new batch size pulled from the queue.
    capacity: An integer. The maximum number of elements in the queue.
    min_after_dequeue: Minimum number elements in the queue after a
      dequeue, used to ensure a level of mixing of elements.
    keep_input: A `bool` Tensor.  This tensor controls whether the input is
      added to the queue or not.  If it is a scalar and evaluates `True`, then
      `tensors` are all added to the queue. If it is a vector and `enqueue_many`
      is `True`, then each example is added to the queue only if the
      corresponding value in `keep_input` is `True`. This tensor essentially
      acts as a filtering mechanism.
    seed: Seed for the random shuffling within the queue.
    enqueue_many: Whether each tensor in `tensor_list_list` is a single
      example.
    shapes: (Optional) The shapes for each example.  Defaults to the
      inferred shapes for `tensors_list[i]`.
    allow_smaller_final_batch: (Optional) Boolean. If `True`, allow the final
      batch to be smaller if there are insufficient items left in the queue.
    shared_name: (optional). If set, this queue will be shared under the given
      name across multiple sessions.
    name: (Optional) A name for the operations.

  Returns:
    A list or dictionary of tensors with the same number and types as
    `tensors_list[i]`.

  Raises:
    ValueError: If the `shapes` are not specified, and cannot be
      inferred from the elements of `tensors_list`.

  @compatibility(eager)
  Input pipelines based on Queues are not supported when eager execution is
  enabled. Please use the `tf.data` API to ingest data under eager execution.
  @end_compatibility
  )r9   rH   r;   r  r<   r   r  )r   r  r:   r  r   r9   rH   r;   r  r<   r   r#   r#   r$   maybe_shuffle_batch_join  s    2r  )N)NN)	NNTNr4   NNNN)NTNr4   NNN)NTNr4   NN)NTNr4   NN)N)r8   r4   FNFFNN)r4   FNFFNN)r8   NFNFNN)NFNFNN)r8   r4   FNFFNN)r8   r4   FNFFNN)r4   FNFFNN)r4   FNFFNN)r8   NFNFNN)r8   NFNFNN)NFNFNN)NFNFNN)Lr   tensorflow.python.eagerr   tensorflow.python.frameworkr   r   r   r   r   tensorflow.python.layersr   tensorflow.python.opsr	   r
   r   r   r   r   r   r   r   tensorflow.python.summaryr   tensorflow.python.trainingr   tensorflow.python.utilr   Ztensorflow.python.util.compatr    tensorflow.python.util.tf_exportr   _add_sparse_to_tensors_mapr   _add_many_sparse_to_tensors_mapr   "_take_many_sparse_from_tensors_mapr   deprecated_endpointsr%   
deprecatedr&   r6   rZ   r]   rk   rn   objectro   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r  r  r   r  r
  r  r  r  r  r  r#   r#   r#   r$   <module>   sb  
 
         R
       E
  %
  6; 
f!	    
(   
$   
-    
-
   ^
   4
   i
    4
  c
    ;
   ]
    