code: def _is_mask_valid(mask: Tensor, inp: Tensor) -> bool:
      """
      Checks whether the mask is valid for the given input.
      """
      if mask.dim() > inp.dim():
          return False
  
      for mask_d, inp_d in zip(mask.shape[::-1], inp.shape[::-1]):
          if mask_d != 1 and mask_d != inp_d:
              return False
  
      return True
  
imports: import typing
  from enum import Enum
  from functools import reduce
  from inspect import signature
  from typing import Any, Callable, cast, Dict, List, overload, Tuple, Union
  import numpy
  import torch
  from captum._utils.typing import BaselineType, Literal, TargetType, TensorOrTupleOfTensorsGeneric, TupleOrTensorOrBoolGeneric
  from torch import device, Tensor
  from torch.nn import Module
label_desc: Use image node_id 10 for calling a global function with example usage: _is_mask_valid(mask, inp) and returns: True, False, False