code: def drop_nan(
      x: np.ndarray,
      y: Optional[np.ndarray],
      x_nan_mask: np.ndarray,
      y_nan_mask: Optional[np.ndarray],
      *,
      only_drop_y: bool,
  ) -> TArrayPair:
      if y_nan_mask is not None:
          y_nan_mask = np.any(y_nan_mask, axis=1)
      if not only_drop_y:
          x_nan_mask = np.any(x_nan_mask, axis=1)
          if y_nan_mask is None:
              nan_mask = x_nan_mask
          else:
              nan_mask = x_nan_mask | y_nan_mask
      else:
          if y_nan_mask is None:
              return x, y
          nan_mask = y_nan_mask
      valid_mask = ~nan_mask
      return x[valid_mask], None if y is None else y[valid_mask]
  
imports: import numpy
  from enum import Enum
  from typing import Any
  from typing import Dict
  from typing import Optional
  from dataclasses import dataclass
  from .file import TArrayPair
  from .file import FileParserBlock
  from ....schema import DataBundle
  from ....schema import INoInitDataBlock
label_desc: Use image node_id 1 for calling a global function with example usage: drop_nan(x, y, x_nan_mask, y_nan_mask) and returns: x,  unknown, x,  y