code: def visualize(self, show_ports=False):
          
          nglview = import_('nglview')
          from mdtraj.geometry.sasa import _ATOMIC_RADII
          if run_from_ipython():
              remove_digits = lambda x: ''.join(i for i in x if not i.isdigit()
                                                or i == '_')
              for particle in self.particles():
                  particle.name = remove_digits(particle.name).upper()
                  if not particle.name:
                      particle.name = 'UNK'
              tmp_dir = tempfile.mkdtemp()
              self.save(os.path.join(tmp_dir, 'tmp.mol2'),
                        show_ports=show_ports,
                        overwrite=True)
              widget = nglview.show_file(os.path.join(tmp_dir, 'tmp.mol2'))
              widget.clear()
              widget.add_ball_and_stick(cylinderOnly=True)
              elements = set([particle.name for particle in self.particles()])
              scale = 50.0
              for element in elements:
                  try:
                      widget.add_ball_and_stick('_{}'.format(
                          element.upper()), aspect_ratio=_ATOMIC_RADII[element.title()]**1.5 * scale)
                  except KeyError:
                      ids = [str(i) for i, particle in enumerate(self.particles())
                             if particle.name == element]
                      widget.add_ball_and_stick(
                          '@{}'.format(
                              ','.join(ids)),
                          aspect_ratio=0.17**1.5 * scale,
                          color='grey')
              if show_ports:
                  widget.add_ball_and_stick('_VS',
                                            aspect_ratio=1.0, color='#991f00')
              return widget
          else:
              raise RuntimeError('Visualization is only supported in Jupyter '
                                 'Notebooks.')
docs: Visualize the Compound using nglview.
  
          Allows for visualization of a Compound within a Jupyter Notebook.
  
          Parameters
          ----------
          show_ports : bool, optional, default=False
              Visualize Ports in addition to Particles