code: def _se_pool_step_script_infer(
      x: torch.Tensor, context_window: int, mask: torch.Tensor
  ):
      """
      Calculates the masked average over padded limited context segment during inference mode.
  
      Args:
          x: Input tensor. Shape = [B, C, T]
          context_window: Integer context window, must be 0 or greater.
          mask: Mask tensor, 1 represents value index, 0 represents padded index. Shape = [B, 1, T].
  
      Returns:
          A tensor reduced via masked average pool over some limited context. Shape = [B, C, 1]
      """
      timesteps = x.shape[-1]
      if timesteps < context_window:
          y = torch.sum(x, dim=-1, keepdim=True) / mask.sum(
              dim=-1, keepdim=True
          ).to(x.dtype)
      else:
          # << During inference prefer to use entire context >>
          # x = x[:, :, :context_window]  # [B, C, context_window]
          # mask = mask[:, :, :context_window]  # [B, 1, context_window]
          #
          # mask = mask.sum(dim=-1, keepdim=True).to(x.dtype)  # [B, C, 1]
          # y = x.sum(dim=-1, keepdim=True)  # [B, 1, 1]
          # y = y / (mask + 1e-8)  # [B, C, 1]
          y = torch.sum(x, dim=-1, keepdim=True) / mask.sum(
              dim=-1, keepdim=True
          ).to(x.dtype)
  
      return y
  
imports: import math
  from typing import Callable, Iterable, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from torch.nn.init import _calculate_correct_fan
  from torch.nn.modules.utils import _single
  from nemo.collections.common.parts.utils import activation_registry
  from nemo.core.classes.mixins import AccessMixin
  from nemo.core.classes.mixins.adapter_mixins import AdapterModuleMixin
  from nemo.utils import logging
label_desc: Use image node_id 7 for calling a global function with example usage: _se_pool_step_script_infer(x, context_window, mask) and returns: y