class_docstr: A projective dependency CRF.
  
  Parameters:
      arc_scores_in: Arc scores of shape (B, N, N) or (B, N, N, L) with root scores on
      diagonal.
  
  Note: For single-root case, do not set cache=True for now.
class_docstr_tok: ["A","projective","dependency","CRF",".","Parameters",":","arc_scores_in",":","Arc","scores","of","shape","(","B",",","N",",","N",")","or","(","B",",","N",",","N",",","L",")","with","root","scores","on","diagonal",".","Note",":","For","single-root","case",",","do","not","set","cache=True","for","now","."]
code: def _check_potentials(self, arc_scores, lengths=None):
      semiring = self.semiring
      batch, N, N2, *_ = self._get_dimension(arc_scores)
      assert N == N2, "Non-square potentials"
      if lengths is None:
          lengths = torch.LongTensor([N - 1] * batch).to(
              arc_scores.device
          )
      assert max(lengths) <= N, "Length longer than N"
      arc_scores = semiring.convert(arc_scores)
  
      # Set the extra elements of the log-potentials to zero.
      keep = torch.ones_like(arc_scores).bool()
      for b in range(batch):
          keep[:, b, lengths[b] + 1 :, :].fill_(0.0)
          keep[:, b, :, lengths[b] + 1 :].fill_(0.0)
      arc_scores = semiring.fill(arc_scores, ~keep, semiring.zero)
      return arc_scores, batch, N, lengths
  
file_path: pytorch-struct/torch_struct/deptree.py
imports: import torch
  from .helpers import _Struct, Chart
label_desc: Use image node_id 2 for calling the DepTree obj's underlying member method code with example usage: obj._check_potentials(arc_scores, lengths) and returns: arc_scores,  batch,  N,  lengths