# Path: difflogic/nn/neural_logic/modules/_utils.py
# def exclude_mask(inputs, cnt=2, dim=1):
# def mask_value(inputs, mask, value):


import torch
import torch.nn as nn
from jacinle.utils.enum import JacEnum
from ._utils import meshgrid, meshgrid_exclude_self
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Implement transformation for input tensors."""




__all__ = ['InputTransformMethod', 'InputTransform']


class InputTransformMethod(JacEnum):
  CONCAT = 'concat'
  DIFF = 'diff'
  CMP = 'cmp'


class InputTransform(nn.Module):
  """Transform the unary predicates to binary predicates by operations."""

  def __init__(self, method, exclude_self=True):
    super().__init__()
    self.method = InputTransformMethod.from_string(method)
    self.exclude_self = exclude_self

  def forward(self, inputs):
    assert inputs.dim() == 3


# Path: difflogic/nn/neural_logic/modules/_utils.py
# def exclude_mask(inputs, cnt=2, dim=1):
# def mask_value(inputs, mask, value):


# Path: difflogic/nn/neural_logic/modules/input_transform.py
import torch
import torch.nn as nn
from jacinle.utils.enum import JacEnum
from ._utils import meshgrid, meshgrid_exclude_self

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Implement transformation for input tensors."""




__all__ = ['InputTransformMethod', 'InputTransform']


class InputTransformMethod(JacEnum):
  CONCAT = 'concat'
  DIFF = 'diff'
  CMP = 'cmp'


class InputTransform(nn.Module):
  """Transform the unary predicates to binary predicates by operations."""

  def __init__(self, method, exclude_self=True):
    super().__init__()
    self.method = InputTransformMethod.from_string(method)
    self.exclude_self = exclude_self

  def forward(self, inputs):
    assert inputs.dim() == 3


    x, y = meshgrid(inputs, dim=1)