
    BVh	                     J    d Z ddlmZ ddlmZ ddlmZ ddlmZ d Z	d Z
d Zy	)
z*Utilities related to distributed training.    )distribute_lib)values)backend)	variablesc                 .    | j                   j                  S )N)extended_global_batch_size)distribution_strategys    m/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/keras/distribute/distributed_training_utils.pyglobal_batch_size_supportedr      s    		'	'	:	::    c                 r   d}d|v r|j                  d      }n(t        j                         rt        j                         }t	        j
                  |      }|sM|rKt        j                         r7|j                         5  |j                  j                  | ||      cddd       S  | |i |S # 1 sw Y   xY w)a+  Call a function that uses replica-local variables.

  This function correctly handles calling `fn` in a cross-replica
  context.

  Args:
    fn: The function to call.
    *args: Positional arguments to the `fn`.
    **kwargs: Keyword argument to `fn`.

  Returns:
    The result of calling `fn`.
  Nstrategy)
popr   has_strategyget_strategyr   is_tpu_strategyin_cross_replica_contextscoper   call_for_each_replica)fnargskwargsr   is_tpus        r   call_replica_local_fnr      s      (6zz*%H""$,,.h ""8,&xN$K$K$M		 G44RvFG G	T	V	G Gs   >B--B6c                 n    t        | t        j                        xr t        | t        j                        S )z.Returns whether `v` is a distributed variable.)
isinstance
values_libDistributedValuesr   Variable)vs    r   is_distributed_variabler"   >   s,    
Q
44
5 ,
Q	**
+-r   N)__doc__tensorflow.python.distributer   r   r   tensorflow.python.kerasr   tensorflow.python.opsr   r   r   r"    r   r   <module>r(      s'    1 8 = + +;>-r   