parameters: (clipvalue)
return_statement: return gradient_clipvalue_fn
docstring: Creates a gradient transformation function for clipping by value.
docstring_summary: Creates a gradient transformation function for clipping by value.
docstring_tokens: Creates a gradient transformation function for clipping by value .
function: def make_gradient_clipvalue_fn(clipvalue):
    """Creates a gradient transformation function for clipping by value."""
    if clipvalue is None:
      return lambda grads_and_vars: grads_and_vars
  
    def gradient_clipvalue_fn(grads_and_vars):
  
      if isinstance(distribute_ctx.get_strategy(),
                    (central_storage_strategy.CentralStorageStrategy,
                     central_storage_strategy.CentralStorageStrategyV1)):
        raise ValueError(
            "`clipvalue` is not supported with `CenteralStorageStrategy`")
  
      clipped_grads_and_vars = [(clip_ops.clip_by_value(g, -clipvalue,
                                                        clipvalue), v)
                                for g, v in grads_and_vars]
      return clipped_grads_and_vars
  
    return gradient_clipvalue_fn
function_tokens: def make_gradient_clipvalue_fn ( clipvalue ) : if clipvalue is None : return lambda grads_and_vars : grads_and_vars def gradient_clipvalue_fn ( grads_and_vars ) : if isinstance ( distribute_ctx . get_strategy ( ) , ( central_storage_strategy . CentralStorageStrategy , central_storage_strategy . CentralStorageStrategyV1 ) ) : raise ValueError ( "`clipvalue` is not supported with `CenteralStorageStrategy`" ) clipped_grads_and_vars = [ ( clip_ops . clip_by_value ( g , - clipvalue , clipvalue ) , v ) for g , v in grads_and_vars ] return clipped_grads_and_vars return gradient_clipvalue_fn