code: def nearby_enemy(board, ship, ignore_teammates=False):
      ship_position = transform_position(ship.position)
  
      if ignore_teammates:
          enemy_positions = [
              transform_position(enemy_ship.position)
              for enemy_ship in board.ships.values()
              if enemy_ship.id != ship.id
              and enemy_ship.player.id != ship.player.id
          ]
      else:
          enemy_positions = [
              transform_position(enemy_ship.position)
              for enemy_ship in board.ships.values()
              if enemy_ship.id != ship.id
          ]
  
      enemy_positions.extend(
          [
              transform_position(enemy_shipyard.position)
              for enemy_shipyard in board.shipyards.values()
              if enemy_shipyard.player.id != ship.player.id
          ]
      )
  
      if len(enemy_positions):
          original_distance = min(
              [
                  mahattan_distance(ship_position, enemy_position)
                  for enemy_position in enemy_positions
              ]
          )
  
          if original_distance < 3:
              actions = [
                  ShipAction.UP,
                  ShipAction.DOWN,
                  ShipAction.LEFT,
                  ShipAction.RIGHT,
              ]
  
              tmp = []
  
              for action in actions:
                  new_position = get_new_position(ship_position, action)
                  new_distance = min(
                      [
                          mahattan_distance(
                              new_position, enemy_position
                          )
                          for enemy_position in enemy_positions
                      ]
                  )
                  tmp.append(new_distance - original_distance)
  
              max_dis = max(tmp)
              index = []
              for direct, value in enumerate(tmp):
                  if value == max_dis:
                      index.append(direct)
              index = random.choice(index)
              # index = tmp.index(max(tmp))
  
              return actions[index]
  
      return None
  
imports: import pickle
  import base64
  import random
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.distributions import Categorical
  from zerosum_env.envs.halite.helpers import *
  from zerosum_env import make, evaluate
  from collections import deque
  import os
label_desc: Use image node_id 9 for calling a global function with example usage: nearby_enemy(board, ship, ignore_teammates) and returns: None, actions