class_docstr: A model for restoring punctuation and capitalization in text using lexical and audio features.
  
  The model consists of a language model and two multilayer perceptrons (MLP) on top the fusion of LM and AM. The first
  MLP serves for punctuation prediction and the second is for capitalization prediction. You can use only BERT-like
  HuggingFace language models (model ``forward`` method accepts ``input_ids``, ``token_types_ids``,
  ``attention_mask`` arguments). See more about model config options :ref:`here<model-config-label>`.
  And any :class:`~nemo.collections.asr.models.EncDecCTCModel` which has encoder module which is used as an AM.
  
  For training and testing use dataset
  :class:`~nemo.collections.nlp.data.token_classification.punctuation_capitalization_dataset.BertPunctuationCapitalizationDataset` with parameter ``use_audio`` set to ``True``,
  for training on huge amounts of data which cannot be loaded into memory simultaneously use
  :class:`~nemo.collections.nlp.data.token_classification.punctuation_capitalization_tarred_dataset.BertPunctuationCapitalizationTarredDataset` with parameter ``use_audio`` set to ``True``.
  
  Args:
      cfg: a model configuration. It should follow dataclass
          :class:`~nemo.collections.nlp.models.token_classification.punctuation_capitalization_config.PunctuationCapitalizationLexicalAudioModelConfig`
          See an example of full config in
          `nemo/examples/nlp/token_classification/conf/punctuation_capitalization_lexical_audio_config.yaml
          <https://github.com/NVIDIA/NeMo/blob/main/examples/nlp/token_classification/conf/punctuation_capitalization_lexical_audio_config.yaml>`_
      trainer: an instance of a PyTorch Lightning trainer
class_docstr_tok: ["A","model","for","restoring","punctuation","and","capitalization","in","text","using","lexical","and","audio","features",".","The","model","consists","of","a","language","model","and","two","multilayer","perceptrons","(","MLP",")","on","top","the","fusion","of","LM","and","AM",".","The","first","MLP","serves","for","punctuation","prediction","and","the","second","is","for","capitalization","prediction",".","You","can","use","only","BERT-like","HuggingFace","language","models","(","model","``","forward","``","method","accepts","``","input_ids","``",",","``","token_types_ids","``",",","``","attention_mask","``","arguments",")",".","See","more","about","model","config","options",":","ref",":","`","here","<","model-config-label",">","`",".","And","any",":","class",":","`","~nemo.collections.asr.models.EncDecCTCModel","`","which","has","encoder","module","which","is","used","as","an","AM",".","For","training","and","testing","use","dataset",":","class",":","`","~nemo.collections.nlp.data.token_classification.punctuation_capitalization_dataset.BertPunctuationCapitalizationDataset","`","with","parameter","``","use_audio","``","set","to","``","True","``",",","for","training","on","huge","amounts","of","data","which","can","not","be","loaded","into","memory","simultaneously","use",":","class",":","`","~nemo.collections.nlp.data.token_classification.punctuation_capitalization_tarred_dataset.BertPunctuationCapitalizationTarredDataset","`","with","parameter","``","use_audio","``","set","to","``","True","``",".","Args",":","cfg",":","a","model","configuration",".","It","should","follow","dataclass",":","class",":","`","~nemo.collections.nlp.models.token_classification.punctuation_capitalization_config.PunctuationCapitalizationLexicalAudioModelConfig","`","See","an","example","of","full","config","in","`","nemo\/examples\/nlp\/token_classification\/conf\/punctuation_capitalization_lexical_audio_config.yaml","<","https",":","\/\/github.com\/NVIDIA\/NeMo\/blob\/main\/examples\/nlp\/token_classification\/conf\/punctuation_capitalization_lexical_audio_config.yaml",">","`","_","trainer",":","an","instance","of","a","PyTorch","Lightning","trainer"]
code: def update_max_seq_length(self, seq_length: int, device):
      if torch.distributed.is_initialized():
          global_max_len = torch.tensor(
              [seq_length], dtype=torch.float32, device=device
          )
  
          # Update across all ranks in the distributed system
          torch.distributed.all_reduce(
              global_max_len, op=torch.distributed.ReduceOp.MAX
          )
  
          seq_length = global_max_len.int().item()
  
      if seq_length > self.max_audio_length:
          self.set_max_audio_length(seq_length)
  
imports: import os
  from math import ceil
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from omegaconf import DictConfig, open_dict
  from pytorch_lightning import Trainer
  from torch.nn import Linear
  from tqdm import tqdm
  from nemo.collections.common.losses.cross_entropy import CrossEntropyLoss
  from nemo.collections.nlp.models.token_classification.punctuation_capitalization_model import PunctuationCapitalizationModel
  from nemo.collections.nlp.modules.common.transformer import TransformerDecoder
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.core.classes.mixins import adapter_mixins
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling the PunctuationCapitalizationLexicalAudioModel obj's underlying member method code with example usage: obj.update_max_seq_length(seq_length, device) without return types