code: def safe_shrink(
      vector: type_alias.TensorLike,
      minval: Optional[type_alias.TensorLike] = None,
      maxval: Optional[type_alias.TensorLike] = None,
      open_bounds: bool = False,
      eps: Optional[type_alias.Float] = None,
      name: str = "safe_shrink",
  ) -> tf.Tensor:
      """Shrinks vector by (1.0 - eps) based on its dtype.
  
      This function shrinks the input vector by a very small amount to ensure that
      it is not outside of expected range because of floating point precision
      of operations, e.g. dot product of a normalized vector with itself can
      be greater than `1.0` by a small amount determined by the `dtype` of the
      vector. This function can be used to shrink it without affecting its
      derivative (unlike tf.clip_by_value) and make it safe for other operations
      like `acos(x)`. If the tf-graphics debug flag is set to `True`, this function
      adds assertions to the graph that explicitly check that the vector is in the
      range `[minval, maxval]` when open_bounds is `False`, or in range `]minval,
      maxval[` when open_bounds is `True`.
  
      Note:
        In the following, A1 to An are optional batch dimensions, which must be
        broadcast compatible.
  
      Args:
        vector: A tensor of shape `[A1, ..., An]`.
        minval: A `float` or a tensor of shape `[A1, ..., An]`, which contains the
          the lower bounds for tensor values after shrinking to test against. This
          is only used when both `minval` and `maxval` are not `None`.
        maxval: A `float` or a tensor of shape `[A1, ..., An]`, which contains the
          the upper bounds for tensor values after shrinking to test against. This
          is only used when both `minval` and `maxval` are not `None`.
        open_bounds: A `bool` indicating whether the assumed range is open or
          closed, only to be used when both `minval` and `maxval` are not `None`.
        eps: A `float` that is used to shrink the `vector`. If left as `None`, its
          value is automatically determined from the `dtype` of `vector`.
        name: A name for this op. Defaults to 'safe_shrink'.
  
      Raises:
        InvalidArgumentError: If tf-graphics debug flag is set and the vector is not
          inside the expected range.
  
      Returns:
        A tensor of shape `[A1, ..., An]` containing the shrinked values.
      """
      with tf.name_scope(name):
          vector = tf.convert_to_tensor(value=vector)
          if eps is None:
              eps = asserts.select_eps_for_addition(vector.dtype)
          eps = tf.convert_to_tensor(value=eps, dtype=vector.dtype)
  
          vector *= 1.0 - eps
          if minval is not None and maxval is not None:
              vector = asserts.assert_all_in_range(
                  vector, minval, maxval, open_bounds=open_bounds
              )
          return vector
  
file_path: graphics/tensorflow_graphics/util/safe_ops.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional
  import numpy
  import tensorflow
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 3 for calling a global function with example usage: safe_shrink(vector, minval, maxval, open_bounds, eps, name) and returns: vector