class_docstr: Transformer-based model on PyTorch for syntax parsing. It predicts probabilities of heads and
     dependency ids for text tokens. 
  
  Args:
      pretrained_bert: pretrained Bert checkpoint path or key title (e.g. "bert-base-uncased")
      n_deps: number of syntax dependencies
      encoder_layer_ids: list of indexes of encoder layers which will be used for further predicting of heads and
          dependencies with biaffine layer
      state_size: size of dense layers which follow after transformer encoder
      attention_probs_keep_prob: keep_prob for Bert self-attention layers
      hidden_keep_prob: keep_prob for Bert hidden layers
      bert_config_file: path to Bert configuration file, or None, if `pretrained_bert` is a string name
class_docstr_tok: ["Transformer-based","model","on","PyTorch","for","syntax","parsing",".","It","predicts","probabilities","of","heads","and","dependency","ids","for","text","tokens",".","Args",":","pretrained_bert",":","pretrained","Bert","checkpoint","path","or","key","title","(","e.g",".","``","bert-base-uncased","''",")","n_deps",":","number","of","syntax","dependencies","encoder_layer_ids",":","list","of","indexes","of","encoder","layers","which","will","be","used","for","further","predicting","of","heads","and","dependencies","with","biaffine","layer","state_size",":","size","of","dense","layers","which","follow","after","transformer","encoder","attention_probs_keep_prob",":","keep_prob","for","Bert","self-attention","layers","hidden_keep_prob",":","keep_prob","for","Bert","hidden","layers","bert_config_file",":","path","to","Bert","configuration","file",",","or","None",",","if","`","pretrained_bert","`","is","a","string","name"]
docstr: Args:
      input_ids: indices of the subwords
      input_masks: mask that determines where to attend and where not to
      y_masks: mask which determines the first subword units in the the word
      y_heads: for each token - id fo token which is the head in syntax tree for the token
      y_dep: syntax dependencies for each tokens
docstr_tok: ["Args",":","input_ids",":","indices","of","the","subwords","input_masks",":","mask","that","determines","where","to","attend","and","where","not","to","y_masks",":","mask","which","determines","the","first","subword","units","in","the","the","word","y_heads",":","for","each","token","-","id","fo","token","which","is","the","head","in","syntax","tree","for","the","token","y_dep",":","syntax","dependencies","for","each","tokens"]
code: def train_on_batch(
      self,
      input_ids: Union[List[List[int]], np.ndarray],
      input_masks: Union[List[List[int]], np.ndarray],
      y_masks: Union[List[List[int]], np.ndarray],
      y_heads: List[List[int]],
      y_dep: List[List[int]],
  ) -> Dict:
      """
  
      Args:
          input_ids: indices of the subwords
          input_masks: mask that determines where to attend and where not to
          y_masks: mask which determines the first subword units in the the word
          y_heads: for each token - id fo token which is the head in syntax tree for the token
          y_dep: syntax dependencies for each tokens
      """
      self.optimizer.zero_grad()
      loss = self.model(input_ids, input_masks, y_masks, y_heads, y_dep)
      loss.backward()
      # Clip the norm of the gradients to 1.0.
      # This is to help prevent the "exploding gradients" problem.
      if self.clip_norm:
          torch.nn.utils.clip_grad_norm_(
              self.model.parameters(), self.clip_norm
          )
  
      self.optimizer.step()
  
      return {"loss": loss.item()}
  
imports: import math
  from logging import getLogger
  from pathlib import Path
  from typing import List, Dict, Union, Optional, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from transformers import AutoConfig, AutoModel
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.torch_model import TorchModel
  from deeppavlov.models.torch_bert.torch_transformers_sequence_tagger import token_from_subtoken
label_desc: Use image node_id 2 for calling the TorchTransformersSyntaxParser obj's underlying member method code with example usage: obj.train_on_batch(input_ids, input_masks, y_masks, y_heads, y_dep) and returns: dict