class_docstr: TorchAudio Hubert Pretrain model
class_docstr_tok: ["TorchAudio","Hubert","Pretrain","model"]
docstr: Compute the cross-entropy loss on HuBERT masked and non-masked logits.
  
  Args:
      logit_m (Tensor or None): The masked logit Tensor of dimension
          `(masked_frames, final_dim)`.
      logit_u (Tensor or None): The non-masked logit Tensor of dimension
          `(unmasked_frames, final_dim)`.
      feature_penalty (Tensor): The feature mean value for additional penalty
          loss.
      masked_weight (float, optional): The weight for masked cross-entropy loss
          (Default: ``1.0``).
      unmasked_weight (float, optional): The weight for non-masked cross-entropy
          loss (Default: ``0.0``).
      feature_weight (float, optional): The weight for feature penalty loss
          (Default: ``10.0``).
      reduction (str, optional): The reduction method for cross-entropy loss
          (Default: ``"sum"``).
  Ref:
      torchaudio: examples/hubert/loss/hubert_loss.py
docstr_tok: ["Compute","the","cross-entropy","loss","on","HuBERT","masked","and","non-masked","logits",".","Args",":","logit_m","(","Tensor","or","None",")",":","The","masked","logit","Tensor","of","dimension","`","(","masked_frames",",","final_dim",")","`",".","logit_u","(","Tensor","or","None",")",":","The","non-masked","logit","Tensor","of","dimension","`","(","unmasked_frames",",","final_dim",")","`",".","feature_penalty","(","Tensor",")",":","The","feature","mean","value","for","additional","penalty","loss",".","masked_weight","(","float",",","optional",")",":","The","weight","for","masked","cross-entropy","loss","(","Default",":","``","1.0","``",")",".","unmasked_weight","(","float",",","optional",")",":","The","weight","for","non-masked","cross-entropy","loss","(","Default",":","``","0.0","``",")",".","feature_weight","(","float",",","optional",")",":","The","weight","for","feature","penalty","loss","(","Default",":","``","10.0","``",")",".","reduction","(","str",",","optional",")",":","The","reduction","method","for","cross-entropy","loss","(","Default",":","``","``","sum","''","``",")",".","Ref",":","torchaudio",":","examples\/hubert\/loss\/hubert_loss.py"]
code: def _calc_hubert_loss(
      self,
      logit_m: Optional[torch.Tensor],
      logit_u: Optional[torch.Tensor],
      feature_penalty: torch.Tensor,
      masked_weight: float = 1.0,
      unmasked_weight: float = 0.0,
      feature_weight: float = 10.0,
      reduction: str = "sum",
  ) -> torch.Tensor:
      """Compute the cross-entropy loss on HuBERT masked and non-masked logits.
  
      Args:
          logit_m (Tensor or None): The masked logit Tensor of dimension
              `(masked_frames, final_dim)`.
          logit_u (Tensor or None): The non-masked logit Tensor of dimension
              `(unmasked_frames, final_dim)`.
          feature_penalty (Tensor): The feature mean value for additional penalty
              loss.
          masked_weight (float, optional): The weight for masked cross-entropy loss
              (Default: ``1.0``).
          unmasked_weight (float, optional): The weight for non-masked cross-entropy
              loss (Default: ``0.0``).
          feature_weight (float, optional): The weight for feature penalty loss
              (Default: ``10.0``).
          reduction (str, optional): The reduction method for cross-entropy loss
              (Default: ``"sum"``).
      Ref:
          torchaudio: examples/hubert/loss/hubert_loss.py
      """
      loss = feature_penalty * feature_weight * logit_m.shape[0]
      if logit_m is not None:
          target_m = torch.zeros(
              logit_m.shape[0], dtype=torch.long, device=logit_m.device
          )
          loss_m = torch.nn.functional.cross_entropy(
              logit_m, target_m, reduction=reduction
          )
          loss += loss_m * masked_weight
      if logit_u is not None:
          target_u = torch.zeros(
              logit_u.shape[0], dtype=torch.long, device=logit_m.device
          )
          loss_u = torch.nn.functional.cross_entropy(
              logit_u, target_u, reduction=reduction
          )
          loss += loss_u * unmasked_weight
      return loss
  
imports: import logging
  from contextlib import contextmanager
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.preencoder.abs_preencoder import AbsPreEncoder
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.hubert.hubert_loss import HubertPretrainLoss
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet.nets.e2e_asr_common import ErrorCalculator
label_desc: Use image node_id 7 for calling the TorchAudioHubertPretrainModel obj's underlying member method code with example usage: obj._calc_hubert_loss(logit_m, logit_u, feature_penalty, masked_weight, unmasked_weight, feature_weight, reduction) and returns: loss