
    AVh9                        d Z ddl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m Z m!Z! ddl"m#Z#  ejH                  dddg      Z%d(de#e!ejL                  f   de#e!ejL                  f   de'de'de'f
dZ(  ed       ejR                  e(            Z*de#e!ejL                  f   de#e!ejL                  f   de'de'de'f
dZ+d(de#e!ejL                  f   de#e!ejL                  f   de#e!ejX                  f   de#e!ejX                  f   d e#e!ejZ                  f   d!e'd"e'd#e'd$e#e!ejZ                  f   fd%Z.  ed&       ejR                  e.            Z/de#e!ejL                  f   de#e!ejL                  f   de#e!ejX                  f   de#e!ejX                  f   d e#e!ejZ                  f   d!e'd"e'd#e'd$e#e!ejZ                  f   fd'Z0y))zUPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
    N)
pywrap_tfe)context)core)execute)dtypes)annotation_types)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_export)TypeVarListAny)	AnnotatedGenerateVocabRemapping	remappingnum_presentnew_vocab_fileold_vocab_filenew_vocab_offsetnum_new_vocabold_vocab_sizec                    t         j                   xs t        j                         }|j                  }|j                  r7	 t	        j
                  |d|| |d|d|d|      }t        j                  |      }|S t        j                   |d      }t        j                   |d      }|d}t        j                   |d      }t#        j$                  d| |||||      \  }
}
}}|dd }t        j&                         rYd|j)                  d      d|j)                  d      d|j)                  d      f}|j*                  }t        j,                  d|||       t        j                  |      }|S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y cw xY w)	a	  Given a path to new and old vocabulary files, returns a remapping Tensor of

  length `num_new_vocab`, where `remapping[i]` contains the row number in the old
  vocabulary that corresponds to row `i` in the new vocabulary (starting at line
  `new_vocab_offset` and up to `num_new_vocab` entities), or `-1` if entry `i`
  in the new vocabulary is not in the old vocabulary.  The old vocabulary is
  constrained to the first `old_vocab_size` entries if `old_vocab_size` is not the
  default value of -1.

  `num_vocab_offset` enables
  use in the partitioned variable case, and should generally be set through
  examining partitioning info.  The format of the files should be a text file,
  with each line containing a single entity within the vocabulary.

  For example, with `new_vocab_file` a text file containing each of the following
  elements on a single line: `[f0, f1, f2, f3]`, old_vocab_file = [f1, f0, f3],
  `num_new_vocab = 3, new_vocab_offset = 1`, the returned remapping would be
  `[0, -1, 2]`.

  The op also returns a count of how many entries in the new vocabulary
  were present in the old vocabulary, which is used to calculate the number of
  values to initialize in a weight matrix remapping

  This functionality can be used to remap both row vocabularies (typically,
  features) and column vocabularies (typically, classes) from TensorFlow
  checkpoints.  Note that the partitioning logic relies on contiguous vocabularies
  corresponding to div-partitioned variables.  Moreover, the underlying remapping
  uses an IndexTable (as opposed to an inexact CuckooTable), so client code should
  use the corresponding index_table_from_file() as the FeatureColumn framework
  does (as opposed to tf.feature_to_id(), which uses a CuckooTable).

  Args:
    new_vocab_file: A `Tensor` of type `string`. Path to the new vocab file.
    old_vocab_file: A `Tensor` of type `string`. Path to the old vocab file.
    new_vocab_offset: An `int` that is `>= 0`.
      How many entries into the new vocab file to start reading.
    num_new_vocab: An `int` that is `>= 0`.
      Number of entries in the new vocab file to remap.
    old_vocab_size: An optional `int` that is `>= -1`. Defaults to `-1`.
      Number of entries in the old vocab file to consider.  If -1,
      use the entire old vocabulary.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (remapping, num_present).

    remapping: A `Tensor` of type `int64`.
    num_present: A `Tensor` of type `int32`.
  r   r   r   r   N)r   r   r   namectx)r   r   r   r   r   r   )_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_GenerateVocabRemappingOutput_make_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackException'generate_vocab_remapping_eager_fallback_SymbolicException_executemake_int_op_def_library_apply_op_helpermust_record_gradient_get_attr_intinputsrecord_gradient)r   r   r   r   r   r   _ctxtld_resulte__op_outputs_attrs_inputs_flats                  X/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_checkpoint_ops.pygenerate_vocab_remappingr>      s   d 
			0h..0$#\\
11&nn,o}.*g .33G<gn &&'79KL##M?C-N$$^5EF.'88 1?3C0=1?dL!QX QK'""$ #"3"34F"Gs00A 1 12B CEF ::L ,A)//8'	.A && -
##At,,## 
4
.;K%n  ## 
s0    5E& &F-9FF-,F-1G GGzraw_ops.GenerateVocabRemappingc                    t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }t        j                  | t        j
                        } t        j                  |t        j
                        }| |g}d|d|d|f}t        j                  dd||||      }	t        j                         rt        j                  d|||	       t        j                  |	      }	|	S )	Nr   r   r   r   s   GenerateVocabRemapping   r2   attrsr   r   r   )r,   r-   r'   convert_to_tensor_dtypesstringr   r0   r3   r#   r$   )
r   r   r   r   r   r   r   r<   r;   r6   s
             r=   r*   r*   ~   s    &&'79KL##M?C-N$$^5EF.)).'..I.)).'..I. .1, 0/!>3&6$0C"&(' ""$ ,A)//8'	.    	ckpt_pathold_tensor_namerow_remappingcol_remappinginitializing_valuesnum_rowsnum_colsmax_rows_in_memoryreturnc	                    t         j                   xs t        j                         }	|	j                  }
|
j                  r%	 t	        j
                  |	d|| ||||d|d|d|      }|S t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }t        j                   d| ||||||||
      \  }}}}|dd }t        j"                         rYd|j%                  d      d|j%                  d      d|j%                  d      f}|j&                  }t        j(                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||||||||	
      S # t        j                  $ r Y Xw xY w)	a  Loads a 2-D (matrix) `Tensor` with name `old_tensor_name` from the checkpoint

  at `ckpt_path` and potentially reorders its rows and columns using the
  specified remappings.

  Most users should use one of the wrapper initializers (such as
  `tf.contrib.framework.load_and_remap_matrix_initializer`) instead of this
  function directly.

  The remappings are 1-D tensors with the following properties:

  * `row_remapping` must have exactly `num_rows` entries. Row `i` of the output
    matrix will be initialized from the row corresponding to index
    `row_remapping[i]` in the old `Tensor` from the checkpoint.
  * `col_remapping` must have either 0 entries (indicating that no column
    reordering is needed) or `num_cols` entries. If specified, column `j` of the
    output matrix will be initialized from the column corresponding to index
    `col_remapping[j]` in the old `Tensor` from the checkpoint.
  * A value of -1 in either of the remappings signifies a "missing" entry. In that
    case, values from the `initializing_values` tensor will be used to fill that
    missing row or column. If `row_remapping` has `r` missing entries and
    `col_remapping` has `c` missing entries, then the following condition must be
    true:

  `(r * num_cols) + (c * num_rows) - (r * c) == len(initializing_values)`

  The remapping tensors can be generated using the GenerateVocabRemapping op.

  As an example, with row_remapping = [1, 0, -1], col_remapping = [0, 2, -1],
  initializing_values = [0.5, -0.5, 0.25, -0.25, 42], and w(i, j) representing
  the value from row i, column j of the old tensor in the checkpoint, the output
  matrix will look like the following:

  [[w(1, 0),  w(1, 2),  0.5],
   [w(0, 0),  w(0, 2), -0.5],
   [0.25,    -0.25,      42]]

  Args:
    ckpt_path: A `Tensor` of type `string`.
      Path to the TensorFlow checkpoint (version 2, `TensorBundle`) from
      which the old matrix `Tensor` will be loaded.
    old_tensor_name: A `Tensor` of type `string`.
      Name of the 2-D `Tensor` to load from checkpoint.
    row_remapping: A `Tensor` of type `int64`.
      An int `Tensor` of row remappings (generally created by
      `generate_vocab_remapping`).  Even if no row remapping is needed, this must
      still be an index-valued Tensor (e.g. [0, 1, 2, ...]), or a shifted
      index-valued `Tensor` (e.g. [8, 9, 10, ...], for partitioned `Variables`).
    col_remapping: A `Tensor` of type `int64`.
      An int `Tensor` of column remappings (generally created by
      `generate_vocab_remapping`).  May be a size-0 `Tensor` if only row remapping
      is to be done (e.g. column ordering is the same).
    initializing_values: A `Tensor` of type `float32`.
      A float `Tensor` containing  values to fill in for cells
      in the output matrix that are not loaded from the checkpoint. Length must be
      exactly the same as the number of missing / new cells.
    num_rows: An `int` that is `>= 0`.
      Number of rows (length of the 1st dimension) in the output matrix.
    num_cols: An `int` that is `>= 1`.
      Number of columns (length of the 2nd dimension) in the output matrix.
    max_rows_in_memory: An optional `int`. Defaults to `-1`.
      The maximum number of rows to load from the checkpoint at
      once. If less than or equal to 0, the entire matrix will be loaded into
      memory. Setting this arg trades increased disk reads for lower memory usage.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `float32`.
  LoadAndRemapMatrixrL   rM   rN   N)rL   rM   rN   r   r   r   )	rG   rH   rI   rJ   rK   rL   rM   rN   r   )r   r   r    r!   r   r"   r%   r&   r'   r(   r)   $load_and_remap_matrix_eager_fallbackr+   r,   r-   r.   r/   r0   r1   r2   r3   )rG   rH   rI   rJ   rK   rL   rM   rN   r   r4   r5   r6   r7   r8   r9   r:   r;   r<   s                     r=   load_and_remap_matrixrS      s   L 
			0h..0$#\\
11"D)_}&9:*h(<	g
 n x4(x4((();=QR'88	.=,9,92E'/(1C#')!QX QK'""$#++J7
+-A 457F ::LlFG=('	.G && -
##At,,## 
1
_m]
8/dF F ## 
s0    #E FE44FFF& &F=<F=zraw_ops.LoadAndRemapMatrixc
                    t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }t        j                  | t        j
                        } t        j                  |t        j
                        }t        j                  |t        j                        }t        j                  |t        j                        }t        j                  |t        j                        }| ||||g}
d|d|d|f}t        j                  dd|
||	|      }t        j                         rt        j                  d|
||       |\  }|S )	NrL   rM   r   rN   s   LoadAndRemapMatrix   rA   rQ   )r,   r-   r'   rC   rD   rE   int64float32r   r0   r3   )rG   rH   rI   rJ   rK   rL   rM   rN   r   r   r<   r;   r6   s                r=   rR   rR     s+   x4(x4((();=QR$$Y?)**?GNNK/((F-((F-../BGOOT_m]L_`,*h8L&2Al#)s?'""$lFG=('	.rF   )r   N)1__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r   r   r%   r   r,   tensorflow.python.frameworkr   rD   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   r'   r   r.   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   	_dispatch tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   
namedtupler#   Stringintr>   	to_raw_opr   r*   Int64Float32rS   rQ   rR    rF   r=   <module>rm      s  
  6 7 1 7 9 F K 3 I C 8 6 % % ' 6 6 6- !" 
\YsGNN7J-K \]fgjlslzlzgz]{ \  PS \  dg \  x{ \| E#CD^T^^TlEmn Ic7>>FY<Z luvy  |C  |J  |J  wJ  mK   _b   sv   HK *sYsGNN/B%C sV_`celeses`sVt s  FO  PS  U\  Ub  Ub  Pb  Fc s  t}  ~A  CJ  CP  CP  ~P  tQ s  hq  ru  w~  wF  wF  rF  hG s  SV s  be s  z} s  PY  Z]  _f  _n  _n  Zn  Po sj =Y;<^T^^La=bc Ic7>>>Q4R enort{  uC  uC  pC  fD   U^  _b  dk  dq  dq  _q  Ur   CL  MP  RY  R_  R_  M_  C`   w@  AD  FM  FU  FU  AU  wV   be   qt   JM   ]f  gj  ls  l{  l{  g{  ]| rF   