__author__ = "Joseph Gomes"
__copyright__ = "Copyright 2017, Stanford University"
__license__ = "MIT"

import sys

from deepchem.models import KerasModel
from deepchem.models.layers import AtomicConvolution
from deepchem.models.losses import L2Loss
from tensorflow.keras.layers import Input, Layer

import numpy as np
import tensorflow as tf
import itertools


def initializeWeightsBiases(prev_layer_size,
                            size,
                            weights=None,
                            biases=None,
                            name=None):
  """Initializes weights and biases to be used in a fully-connected layer.

  Parameters
  ----------
  prev_layer_size: int
    Number of features in previous layer.
  size: int
    Number of nodes in this layer.
  weights: tf.Tensor, optional (Default None)
    Weight tensor.
  biases: tf.Tensor, optional (Default None)
    Bias tensor.
  name: str
    Name for this op, optional (Defaults to 'fully_connected' if None)

  Returns
  -------
  weights: tf.Variable
    Initialized weights.
  biases: tf.Variable
    Initialized biases.

  """

  if weights is None:
    weights = tf.random.truncated_normal([prev_layer_size, size], stddev=0.01)
  if biases is None:
    biases = tf.zeros([size])

  w = tf.Variable(weights, name='w')
  b = tf.Variable(biases, name='b')
  return w, b


class AtomicConvScore(Layer):
  """The scoring function used by the atomic convolution models."""

  def __init__(self, atom_types, layer_sizes, **kwargs):
    super(AtomicConvScore, self).__init__(**kwargs)
    self.atom_types = atom_types
    self.layer_sizes = layer_sizes

  def build(self, input_shape):
    self.type_weights = []
    self.type_biases = []
    self.output_weights = []
    self.output_biases = []
    n_features = int(input_shape[0][-1])
    layer_sizes = self.layer_sizes
    num_layers = len(layer_sizes)
    weight_init_stddevs = [1 / np.sqrt(x) for x in layer_sizes]
    bias_init_consts = [0.0] * num_layers
    for ind, atomtype in enumerate(self.atom_types):
      prev_layer_size = n_features
      self.type_weights.append([])
      self.type_biases.append([])
      self.output_weights.append([])
      self.output_biases.append([])
      for i in range(num_layers):
        weight, bias = initializeWeightsBiases(
            prev_layer_size=prev_layer_size,
            size=layer_sizes[i],
            weights=tf.random.truncated_normal(
                shape=[prev_layer_size, layer_sizes[i]],
                stddev=weight_init_stddevs[i]),
            biases=tf.constant(
                value=bias_init_consts[i], shape=[layer_sizes[i]]))
        self.type_weights[ind].append(weight)
        self.type_biases[ind].append(bias)
        prev_layer_size = layer_sizes[i]
      weight, bias = initializeWeightsBiases(prev_layer_size, 1)
      self.output_weights[ind].append(weight)
      self.output_biases[ind].append(bias)

  def call(self, inputs):
    frag1_layer, frag2_layer, complex_layer, frag1_z, frag2_z, complex_z = inputs
    atom_types = self.atom_types
    num_layers = len(self.layer_sizes)

    def atomnet(current_input, atomtype):
      prev_layer = current_input
      for i in range(num_layers):
        layer = tf.nn.bias_add(
            tf.matmul(prev_layer, self.type_weights[atomtype][i]),
            self.type_biases[atomtype][i])
        layer = tf.nn.relu(layer)
        prev_layer = layer

      output_layer = tf.squeeze(
          tf.nn.bias_add(
              tf.matmul(prev_layer, self.output_weights[atomtype][0]),
              self.output_biases[atomtype][0]))
      return output_layer

    frag1_zeros = tf.zeros_like(frag1_z, dtype=tf.float32)
    frag2_zeros = tf.zeros_like(frag2_z, dtype=tf.float32)
    complex_zeros = tf.zeros_like(complex_z, dtype=tf.float32)

    frag1_atomtype_energy = []
    frag2_atomtype_energy = []
    complex_atomtype_energy = []

    for ind, atomtype in enumerate(atom_types):
      frag1_outputs = tf.map_fn(lambda x: atomnet(x, ind), frag1_layer)
      frag2_outputs = tf.map_fn(lambda x: atomnet(x, ind), frag2_layer)
      complex_outputs = tf.map_fn(lambda x: atomnet(x, ind), complex_layer)

      cond = tf.equal(frag1_z, atomtype)
      frag1_atomtype_energy.append(tf.where(cond, frag1_outputs, frag1_zeros))
      cond = tf.equal(frag2_z, atomtype)
      frag2_atomtype_energy.append(tf.where(cond, frag2_outputs, frag2_zeros))
      cond = tf.equal(complex_z, atomtype)
      complex_atomtype_energy.append(
          tf.where(cond, complex_outputs, complex_zeros))

    frag1_outputs = tf.add_n(frag1_atomtype_energy)
    frag2_outputs = tf.add_n(frag2_atomtype_energy)
    complex_outputs = tf.add_n(complex_atomtype_energy)

    frag1_energy = tf.reduce_sum(frag1_outputs, 1)
    frag2_energy = tf.reduce_sum(frag2_outputs, 1)
    complex_energy = tf.reduce_sum(complex_outputs, 1)
    binding_energy = complex_energy - (frag1_energy + frag2_energy)
    return tf.expand_dims(binding_energy, axis=1)


class AtomicConvModel(KerasModel):
  """Implements an Atomic Convolution Model.

  Implements the atomic convolutional networks as introduced in

  Gomes, Joseph, et al. "Atomic convolutional networks for predicting protein-ligand binding affinity." arXiv preprint arXiv:1703.10603 (2017).

  The atomic convolutional networks function as a variant of
  graph convolutions. The difference is that the "graph" here is
  the nearest neighbors graph in 3D space. The AtomicConvModel
  leverages these connections in 3D space to train models that
  learn to predict energetic state starting from the spatial
  geometry of the model.
  """

  def __init__(self,
               frag1_num_atoms=70,
               frag2_num_atoms=634,
               complex_num_atoms=701,
               max_num_neighbors=12,
               batch_size=24,
               atom_types=[
                   6, 7., 8., 9., 11., 12., 15., 16., 17., 20., 25., 30., 35.,
                   53., -1.
               ],
               radial=[[
                   1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0,
                   7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5, 11.0, 11.5, 12.0
               ], [0.0, 4.0, 8.0], [0.4]],
               layer_sizes=[32, 32, 16],
               learning_rate=0.001,
               **kwargs):
    """
    Parameters
    ----------
    frag1_num_atoms: int
      Number of atoms in first fragment
    frag2_num_atoms: int
      Number of atoms in sec
    max_num_neighbors: int
      Maximum number of neighbors possible for an atom. Recall neighbors
      are spatial neighbors.
    atom_types: list
      List of atoms recognized by model. Atoms are indicated by their
      nuclear numbers.
    radial: list
      TODO: add description
    layer_sizes: list
      TODO: add description
    learning_rate: float
      Learning rate for the model.
    """
    # TODO: Turning off queue for now. Safe to re-activate?
    self.complex_num_atoms = complex_num_atoms
    self.frag1_num_atoms = frag1_num_atoms
    self.frag2_num_atoms = frag2_num_atoms
    self.max_num_neighbors = max_num_neighbors
    self.batch_size = batch_size
    self.atom_types = atom_types

    rp = [x for x in itertools.product(*radial)]
    frag1_X = Input(shape=(frag1_num_atoms, 3))
    frag1_nbrs = Input(shape=(frag1_num_atoms, max_num_neighbors))
    frag1_nbrs_z = Input(shape=(frag1_num_atoms, max_num_neighbors))
    frag1_z = Input(shape=(frag1_num_atoms,))

    frag2_X = Input(shape=(frag2_num_atoms, 3))
    frag2_nbrs = Input(shape=(frag2_num_atoms, max_num_neighbors))
    frag2_nbrs_z = Input(shape=(frag2_num_atoms, max_num_neighbors))
    frag2_z = Input(shape=(frag2_num_atoms,))

    complex_X = Input(shape=(complex_num_atoms, 3))
    complex_nbrs = Input(shape=(complex_num_atoms, max_num_neighbors))
    complex_nbrs_z = Input(shape=(complex_num_atoms, max_num_neighbors))
    complex_z = Input(shape=(complex_num_atoms,))

    self._frag1_conv = AtomicConvolution(
        atom_types=self.atom_types, radial_params=rp,
        boxsize=None)([frag1_X, frag1_nbrs, frag1_nbrs_z])

    self._frag2_conv = AtomicConvolution(
        atom_types=self.atom_types, radial_params=rp,
        boxsize=None)([frag2_X, frag2_nbrs, frag2_nbrs_z])

    self._complex_conv = AtomicConvolution(
        atom_types=self.atom_types, radial_params=rp,
        boxsize=None)([complex_X, complex_nbrs, complex_nbrs_z])

    score = AtomicConvScore(self.atom_types, layer_sizes)([
        self._frag1_conv, self._frag2_conv, self._complex_conv, frag1_z,
        frag2_z, complex_z
    ])

    model = tf.keras.Model(
        inputs=[
            frag1_X, frag1_nbrs, frag1_nbrs_z, frag1_z, frag2_X, frag2_nbrs,
            frag2_nbrs_z, frag2_z, complex_X, complex_nbrs, complex_nbrs_z,
            complex_z
        ],
        outputs=score)
    super(AtomicConvModel, self).__init__(
        model, L2Loss(), batch_size=batch_size, **kwargs)

  def default_generator(self,
                        dataset,
                        epochs=1,
                        mode='fit',
                        deterministic=True,
                        pad_batches=True):
    batch_size = self.batch_size

    def replace_atom_types(z):

      def place_holder(i):
        if i in self.atom_types:
          return i
        return -1

      return np.array([place_holder(x) for x in z])

    for epoch in range(epochs):
      for ind, (F_b, y_b, w_b, ids_b) in enumerate(
          dataset.iterbatches(
              batch_size, deterministic=True, pad_batches=pad_batches)):
        N = self.complex_num_atoms
        N_1 = self.frag1_num_atoms
        N_2 = self.frag2_num_atoms
        M = self.max_num_neighbors

        batch_size = F_b.shape[0]
        num_features = F_b[0][0].shape[1]
        frag1_X_b = np.zeros((batch_size, N_1, num_features))
        for i in range(batch_size):
          frag1_X_b[i] = F_b[i][0]

        frag2_X_b = np.zeros((batch_size, N_2, num_features))
        for i in range(batch_size):
          frag2_X_b[i] = F_b[i][3]

        complex_X_b = np.zeros((batch_size, N, num_features))
        for i in range(batch_size):
          complex_X_b[i] = F_b[i][6]

        frag1_Nbrs = np.zeros((batch_size, N_1, M))
        frag1_Z_b = np.zeros((batch_size, N_1))
        for i in range(batch_size):
          z = replace_atom_types(F_b[i][2])
          frag1_Z_b[i] = z
        frag1_Nbrs_Z = np.zeros((batch_size, N_1, M))
        for atom in range(N_1):
          for i in range(batch_size):
            atom_nbrs = F_b[i][1].get(atom, "")
            frag1_Nbrs[i, atom, :len(atom_nbrs)] = np.array(atom_nbrs)
            for j, atom_j in enumerate(atom_nbrs):
              frag1_Nbrs_Z[i, atom, j] = frag1_Z_b[i, atom_j]

        frag2_Nbrs = np.zeros((batch_size, N_2, M))
        frag2_Z_b = np.zeros((batch_size, N_2))
        for i in range(batch_size):
          z = replace_atom_types(F_b[i][5])
          frag2_Z_b[i] = z
        frag2_Nbrs_Z = np.zeros((batch_size, N_2, M))
        for atom in range(N_2):
          for i in range(batch_size):
            atom_nbrs = F_b[i][4].get(atom, "")
            frag2_Nbrs[i, atom, :len(atom_nbrs)] = np.array(atom_nbrs)
            for j, atom_j in enumerate(atom_nbrs):
              frag2_Nbrs_Z[i, atom, j] = frag2_Z_b[i, atom_j]

        complex_Nbrs = np.zeros((batch_size, N, M))
        complex_Z_b = np.zeros((batch_size, N))
        for i in range(batch_size):
          z = replace_atom_types(F_b[i][8])
          complex_Z_b[i] = z
        complex_Nbrs_Z = np.zeros((batch_size, N, M))
        for atom in range(N):
          for i in range(batch_size):
            atom_nbrs = F_b[i][7].get(atom, "")
            complex_Nbrs[i, atom, :len(atom_nbrs)] = np.array(atom_nbrs)
            for j, atom_j in enumerate(atom_nbrs):
              complex_Nbrs_Z[i, atom, j] = complex_Z_b[i, atom_j]

        inputs = [
            frag1_X_b, frag1_Nbrs, frag1_Nbrs_Z, frag1_Z_b, frag2_X_b,
            frag2_Nbrs, frag2_Nbrs_Z, frag2_Z_b, complex_X_b, complex_Nbrs,
            complex_Nbrs_Z, complex_Z_b
        ]
        y_b = np.reshape(y_b, newshape=(batch_size, 1))
        yield (inputs, [y_b], [w_b])

[((51, 6, 51, 36), 'tensorflow.Variable', 'tf.Variable', (), '', True, 'import tensorflow as tf\n'), ((52, 6, 52, 35), 'tensorflow.Variable', 'tf.Variable', (), '', True, 'import tensorflow as tf\n'), ((47, 14, 47, 78), 'tensorflow.random.truncated_normal', 'tf.random.truncated_normal', (), '', True, 'import tensorflow as tf\n'), ((49, 13, 49, 29), 'tensorflow.zeros', 'tf.zeros', ({(49, 22, 49, 28): '[size]'}, {}), '([size])', True, 'import tensorflow as tf\n'), ((116, 18, 116, 58), 'tensorflow.zeros_like', 'tf.zeros_like', (), '', True, 'import tensorflow as tf\n'), ((117, 18, 117, 58), 'tensorflow.zeros_like', 'tf.zeros_like', (), '', True, 'import tensorflow as tf\n'), ((118, 20, 118, 62), 'tensorflow.zeros_like', 'tf.zeros_like', (), '', True, 'import tensorflow as tf\n'), ((137, 20, 137, 51), 'tensorflow.add_n', 'tf.add_n', ({(137, 29, 137, 50): 'frag1_atomtype_energy'}, {}), '(frag1_atomtype_energy)', True, 'import tensorflow as tf\n'), ((138, 20, 138, 51), 'tensorflow.add_n', 'tf.add_n', ({(138, 29, 138, 50): 'frag2_atomtype_energy'}, {}), '(frag2_atomtype_energy)', True, 'import tensorflow as tf\n'), ((139, 22, 139, 55), 'tensorflow.add_n', 'tf.add_n', ({(139, 31, 139, 54): 'complex_atomtype_energy'}, {}), '(complex_atomtype_energy)', True, 'import tensorflow as tf\n'), ((141, 19, 141, 50), 'tensorflow.reduce_sum', 'tf.reduce_sum', ({(141, 33, 141, 46): 'frag1_outputs', (141, 48, 141, 49): '1'}, {}), '(frag1_outputs, 1)', True, 'import tensorflow as tf\n'), ((142, 19, 142, 50), 'tensorflow.reduce_sum', 'tf.reduce_sum', ({(142, 33, 142, 46): 'frag2_outputs', (142, 48, 142, 49): '1'}, {}), '(frag2_outputs, 1)', True, 'import tensorflow as tf\n'), ((143, 21, 143, 54), 'tensorflow.reduce_sum', 'tf.reduce_sum', ({(143, 35, 143, 50): 'complex_outputs', (143, 52, 143, 53): '1'}, {}), '(complex_outputs, 1)', True, 'import tensorflow as tf\n'), ((145, 11, 145, 49), 'tensorflow.expand_dims', 'tf.expand_dims', (), '', True, 'import tensorflow as tf\n'), ((209, 14, 209, 47), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((210, 17, 210, 66), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((211, 19, 211, 68), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((212, 14, 212, 45), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((214, 14, 214, 47), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((215, 17, 215, 66), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((216, 19, 216, 68), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((217, 14, 217, 45), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((219, 16, 219, 51), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((220, 19, 220, 70), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((221, 21, 221, 72), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((222, 16, 222, 49), 'tensorflow.keras.layers.Input', 'Input', (), '', False, 'from tensorflow.keras.layers import Input, Layer\n'), ((241, 12, 247, 22), 'tensorflow.keras.Model', 'tf.keras.Model', (), '', True, 'import tensorflow as tf\n'), ((129, 13, 129, 40), 'tensorflow.equal', 'tf.equal', ({(129, 22, 129, 29): 'frag1_z', (129, 31, 129, 39): 'atomtype'}, {}), '(frag1_z, atomtype)', True, 'import tensorflow as tf\n'), ((131, 13, 131, 40), 'tensorflow.equal', 'tf.equal', ({(131, 22, 131, 29): 'frag2_z', (131, 31, 131, 39): 'atomtype'}, {}), '(frag2_z, atomtype)', True, 'import tensorflow as tf\n'), ((133, 13, 133, 42), 'tensorflow.equal', 'tf.equal', ({(133, 22, 133, 31): 'complex_z', (133, 33, 133, 41): 'atomtype'}, {}), '(complex_z, atomtype)', True, 'import tensorflow as tf\n'), ((224, 23, 226, 21), 'deepchem.models.layers.AtomicConvolution', 'AtomicConvolution', (), '', False, 'from deepchem.models.layers import AtomicConvolution\n'), ((228, 23, 230, 21), 'deepchem.models.layers.AtomicConvolution', 'AtomicConvolution', (), '', False, 'from deepchem.models.layers import AtomicConvolution\n'), ((232, 25, 234, 21), 'deepchem.models.layers.AtomicConvolution', 'AtomicConvolution', (), '', False, 'from deepchem.models.layers import AtomicConvolution\n'), ((249, 15, 249, 23), 'deepchem.models.losses.L2Loss', 'L2Loss', ({}, {}), '()', False, 'from deepchem.models.losses import L2Loss\n'), ((72, 31, 72, 41), 'numpy.sqrt', 'np.sqrt', ({(72, 39, 72, 40): 'x'}, {}), '(x)', True, 'import numpy as np\n'), ((107, 16, 107, 33), 'tensorflow.nn.relu', 'tf.nn.relu', ({(107, 27, 107, 32): 'layer'}, {}), '(layer)', True, 'import tensorflow as tf\n'), ((130, 35, 130, 77), 'tensorflow.where', 'tf.where', ({(130, 44, 130, 48): 'cond', (130, 50, 130, 63): 'frag1_outputs', (130, 65, 130, 76): 'frag1_zeros'}, {}), '(cond, frag1_outputs, frag1_zeros)', True, 'import tensorflow as tf\n'), ((132, 35, 132, 77), 'tensorflow.where', 'tf.where', ({(132, 44, 132, 48): 'cond', (132, 50, 132, 63): 'frag2_outputs', (132, 65, 132, 76): 'frag2_zeros'}, {}), '(cond, frag2_outputs, frag2_zeros)', True, 'import tensorflow as tf\n'), ((135, 10, 135, 56), 'tensorflow.where', 'tf.where', ({(135, 19, 135, 23): 'cond', (135, 25, 135, 40): 'complex_outputs', (135, 42, 135, 55): 'complex_zeros'}, {}), '(cond, complex_outputs, complex_zeros)', True, 'import tensorflow as tf\n'), ((208, 21, 208, 47), 'itertools.product', 'itertools.product', ({(208, 39, 208, 46): '*radial'}, {}), '(*radial)', False, 'import itertools\n'), ((279, 20, 279, 61), 'numpy.zeros', 'np.zeros', ({(279, 29, 279, 60): '(batch_size, N_1, num_features)'}, {}), '((batch_size, N_1, num_features))', True, 'import numpy as np\n'), ((283, 20, 283, 61), 'numpy.zeros', 'np.zeros', ({(283, 29, 283, 60): '(batch_size, N_2, num_features)'}, {}), '((batch_size, N_2, num_features))', True, 'import numpy as np\n'), ((287, 22, 287, 61), 'numpy.zeros', 'np.zeros', ({(287, 31, 287, 60): '(batch_size, N, num_features)'}, {}), '((batch_size, N, num_features))', True, 'import numpy as np\n'), ((291, 21, 291, 51), 'numpy.zeros', 'np.zeros', ({(291, 30, 291, 50): '(batch_size, N_1, M)'}, {}), '((batch_size, N_1, M))', True, 'import numpy as np\n'), ((292, 20, 292, 47), 'numpy.zeros', 'np.zeros', ({(292, 29, 292, 46): '(batch_size, N_1)'}, {}), '((batch_size, N_1))', True, 'import numpy as np\n'), ((296, 23, 296, 53), 'numpy.zeros', 'np.zeros', ({(296, 32, 296, 52): '(batch_size, N_1, M)'}, {}), '((batch_size, N_1, M))', True, 'import numpy as np\n'), ((304, 21, 304, 51), 'numpy.zeros', 'np.zeros', ({(304, 30, 304, 50): '(batch_size, N_2, M)'}, {}), '((batch_size, N_2, M))', True, 'import numpy as np\n'), ((305, 20, 305, 47), 'numpy.zeros', 'np.zeros', ({(305, 29, 305, 46): '(batch_size, N_2)'}, {}), '((batch_size, N_2))', True, 'import numpy as np\n'), ((309, 23, 309, 53), 'numpy.zeros', 'np.zeros', ({(309, 32, 309, 52): '(batch_size, N_2, M)'}, {}), '((batch_size, N_2, M))', True, 'import numpy as np\n'), ((317, 23, 317, 51), 'numpy.zeros', 'np.zeros', ({(317, 32, 317, 50): '(batch_size, N, M)'}, {}), '((batch_size, N, M))', True, 'import numpy as np\n'), ((318, 22, 318, 47), 'numpy.zeros', 'np.zeros', ({(318, 31, 318, 46): '(batch_size, N)'}, {}), '((batch_size, N))', True, 'import numpy as np\n'), ((322, 25, 322, 53), 'numpy.zeros', 'np.zeros', ({(322, 34, 322, 52): '(batch_size, N, M)'}, {}), '((batch_size, N, M))', True, 'import numpy as np\n'), ((335, 14, 335, 55), 'numpy.reshape', 'np.reshape', (), '', True, 'import numpy as np\n'), ((105, 12, 105, 65), 'tensorflow.matmul', 'tf.matmul', ({(105, 22, 105, 32): 'prev_layer', (105, 34, 105, 64): 'self.type_weights[atomtype][i]'}, {}), '(prev_layer, self.type_weights[atomtype][i])', True, 'import tensorflow as tf\n'), ((112, 14, 112, 69), 'tensorflow.matmul', 'tf.matmul', ({(112, 24, 112, 34): 'prev_layer', (112, 36, 112, 68): 'self.output_weights[atomtype][0]'}, {}), '(prev_layer, self.output_weights[atomtype][0])', True, 'import tensorflow as tf\n'), ((84, 20, 86, 46), 'tensorflow.random.truncated_normal', 'tf.random.truncated_normal', (), '', True, 'import tensorflow as tf\n'), ((87, 19, 88, 66), 'tensorflow.constant', 'tf.constant', (), '', True, 'import tensorflow as tf\n'), ((300, 51, 300, 70), 'numpy.array', 'np.array', ({(300, 60, 300, 69): 'atom_nbrs'}, {}), '(atom_nbrs)', True, 'import numpy as np\n'), ((313, 51, 313, 70), 'numpy.array', 'np.array', ({(313, 60, 313, 69): 'atom_nbrs'}, {}), '(atom_nbrs)', True, 'import numpy as np\n'), ((326, 53, 326, 72), 'numpy.array', 'np.array', ({(326, 62, 326, 71): 'atom_nbrs'}, {}), '(atom_nbrs)', True, 'import numpy as np\n')]