code: def tucker_mode_dot(
      tucker_tensor,
      matrix_or_vector,
      mode,
      keep_dim=False,
      copy=False,
  ):
      shape, _ = TuckerTensor.validate_tucker_tensor(tucker_tensor)
      core, factors = tucker_tensor
      contract = False
  
      if len(matrix_or_vector.shape) == 2:  # Tensor times matrix
          # Test for the validity of the operation
          if matrix_or_vector.shape[1] != shape[mode]:
              raise ValueError(
                  f"shapes {shape} and {matrix_or_vector.shape} not aligned in"
                  f" mode-{mode} multiplication: {shape[mode]} (mode = {mode}) !="
                  f" {matrix_or_vector.shape[1]} (dim 1 of matrix)"
              )
  
      elif len(matrix_or_vector.shape) == 1:  # Tensor times vector
          if matrix_or_vector.shape[0] != shape[mode]:
              raise ValueError(
                  f"shapes {shape} and {matrix_or_vector.shape} not aligned for"
                  f" mode-{mode} multiplication: {shape[mode]} (mode = {mode}) !="
                  f" {matrix_or_vector.shape[0]} (vector size)"
              )
          if not keep_dim:
              contract = True  # Contract over that mode
      else:
          raise ValueError(
              "Can only take n_mode_product with a vector or a matrix."
          )
  
      if copy:
          factors = [deepcopy(f) for f in factors]
          core = deepcopy(core)
  
      if contract:
          print("contracting mode")
          f = factors.pop(mode)
          core = ivy.mode_dot(
              core, ivy.dot(matrix_or_vector, f), mode=mode
          )
      else:
          factors[mode] = ivy.dot(matrix_or_vector, factors[mode])
  
      return TuckerTensor((core, factors))
  
imports: from .base import FactorizedTensor
  import ivy
  from copy import deepcopy
  import warnings
label_desc: Use image node_id 18 for calling the TuckerTensor obj's underlying member method code with example usage: obj.tucker_mode_dot(tucker_tensor, matrix_or_vector, mode, keep_dim, copy) and returns: TuckerTensor