code: def nan_dot(A, B):
      """
      Returns np.dot(left_matrix, right_matrix) with the convention that
      nan * 0 = 0 and nan * x = nan if x != 0.
  
      Parameters
      ----------
      A, B : ndarray
      """
      # Find out who should be nan due to nan * nonzero
      should_be_nan_1 = np.dot(np.isnan(A), (B != 0))
      should_be_nan_2 = np.dot((A != 0), np.isnan(B))
      should_be_nan = should_be_nan_1 + should_be_nan_2
  
      # Multiply after setting all nan to 0
      # This is what happens if there were no nan * nonzero conflicts
      C = np.dot(np.nan_to_num(A), np.nan_to_num(B))
  
      C[should_be_nan] = np.nan
  
      return C
  
imports: import numpy
  import pandas
  import scipy.linalg
  from statsmodels.tools.data import _is_using_pandas
  from statsmodels.tools.validation import array_like
label_desc: Use image node_id 13 for calling a global function with example usage: nan_dot(A, B) and returns: C