class_docstr: Computes the violations of a certain constraint.
class_docstr_tok: ["Computes","the","violations","of","a","certain","constraint","."]
docstr: Computes the constraint violations given an input constraint.
  
  Given a certain constraint, this metric computes how often the selected
  actions in the trajectory violate the constraint.
  
  Args:
    constraint: an instance of `tf_agents.bandits.policies.BaseConstraint`.
    name: (str) name of the metric
    dtype: dtype of the metric value.
docstr_tok: ["Computes","the","constraint","violations","given","an","input","constraint",".","Given","a","certain","constraint",",","this","metric","computes","how","often","the","selected","actions","in","the","trajectory","violate","the","constraint",".","Args",":","constraint",":","an","instance","of","`","tf_agents.bandits.policies.BaseConstraint","`",".","name",":","(","str",")","name","of","the","metric","dtype",":","dtype","of","the","metric","value","."]
code: def __init__(
      self,
      constraint: constraints.BaseConstraint,
      name: Optional[Text] = "ConstraintViolationMetric",
      dtype: float = tf.float32,
  ):
      """Computes the constraint violations given an input constraint.
  
      Given a certain constraint, this metric computes how often the selected
      actions in the trajectory violate the constraint.
  
      Args:
        constraint: an instance of `tf_agents.bandits.policies.BaseConstraint`.
        name: (str) name of the metric
        dtype: dtype of the metric value.
      """
      self._constraint = constraint
      self.dtype = dtype
      self.constraint_violations = common.create_variable(
          initial_value=0.0,
          dtype=self.dtype,
          shape=(),
          name="constraint_violations",
      )
      super(ConstraintViolationsMetric, self).__init__(name=name)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Callable, Optional, Text
  import gin
  import tensorflow
  from tf_agents.bandits.policies import constraints
  from tf_agents.bandits.specs import utils
  from tf_agents.metrics import tf_metric
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 1 to create a new ConstraintViolationsMetric object from inherited base classes: tf_metric with example: obj = ConstraintViolationsMetric(constraint, name, dtype)