class_docstr: Class for representing a trainable constraint using a neural network.
  
  This constraint class uses a neural network to compute the action feasibility.
  In this case, the loss function needs to be exposed for training the neural
  network weights, typically done by the agent that uses this constraint.
class_docstr_tok: ["Class","for","representing","a","trainable","constraint","using","a","neural","network",".","This","constraint","class","uses","a","neural","network","to","compute","the","action","feasibility",".","In","this","case",",","the","loss","function","needs","to","be","exposed","for","training","the","neural","network","weights",",","typically","done","by","the","agent","that","uses","this","constraint","."]
docstr: Creates a trainable constraint using a neural network.
  
  Args:
    time_step_spec: A `TimeStep` spec of the expected time_steps.
    action_spec: A nest of `BoundedTensorSpec` representing the actions.
    constraint_network: An instance of `tf_agents.network.Network` used to
      provide estimates of action feasibility. The input structure should be
      consistent with the `observation_spec`. If the constraint network is not
      available at construction time, it can be set later on using the
      constraint_network setter.
    error_loss_fn: A function for computing the loss used to train the
      constraint network. The default is `tf.losses.mean_squared_error`.
    name: Python str name of this agent. All variables in this module will
      fall under that name. Defaults to the class name.
code: def __init__(
      self,
      time_step_spec: types.TimeStep,
      action_spec: types.BoundedTensorSpec,
      constraint_network: Optional[types.Network],
      error_loss_fn: types.LossFn = tf.compat.v1.losses.mean_squared_error,
      name: Optional[Text] = "NeuralConstraint",
  ):
      """Creates a trainable constraint using a neural network.
  
      Args:
        time_step_spec: A `TimeStep` spec of the expected time_steps.
        action_spec: A nest of `BoundedTensorSpec` representing the actions.
        constraint_network: An instance of `tf_agents.network.Network` used to
          provide estimates of action feasibility. The input structure should be
          consistent with the `observation_spec`. If the constraint network is not
          available at construction time, it can be set later on using the
          constraint_network setter.
        error_loss_fn: A function for computing the loss used to train the
          constraint network. The default is `tf.losses.mean_squared_error`.
        name: Python str name of this agent. All variables in this module will
          fall under that name. Defaults to the class name.
      """
      super(NeuralConstraint, self).__init__(
          time_step_spec, action_spec, name
      )
  
      self._num_actions = (
          policy_utilities.get_num_actions_from_tensor_spec(action_spec)
      )
      if constraint_network is not None:
          with self.name_scope:
              constraint_network.create_variables()
      self._constraint_network = constraint_network
      self._error_loss_fn = error_loss_fn
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import functools
  from typing import Callable, Iterable, Optional, Text
  import six
  import tensorflow
  import tensorflow_probability
  from tf_agents.bandits.policies import loss_utils
  from tf_agents.bandits.specs import utils
  from tf_agents.policies import utils
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 1 to create a new NeuralConstraint object from inherited base classes: BaseConstraint with example: obj = NeuralConstraint(time_step_spec, action_spec, constraint_network, error_loss_fn, name)