code: def plotlyjs_script(connected: bool = True) -> str:
      """Return plotly activation script in the requirejs enviroment.
  
      Parameters
      ----------
      connected : bool, default True
  
      Returns
      -------
      str
      """
      if connected is True:
          # Connected so we configure requirejs with the plotly CDN
          script = textwrap.dedent(
              """
              {win_config}
              {mathjax_config}
              <script type="text/javascript">
                  if (typeof require !== 'undefined') {{
                      require.undef("plotly");
                      requirejs.config({{
                          paths: {{'plotly': ['{plotly_cdn}']}}
                      }});
                      require(
                          ['plotly'],
                          function(Plotly) {{
                              window._Plotly = Plotly;
                              window.Plotly = Plotly;
                              console.log('Loaded plotly successfully');
                          }},
                          function() {{console.log('Failed to load plotly')}}
                      );
                  }} else {{
                      console.log('requirejs is not present');
                  }}
              </script>
          """
          )
          return script.format(
              win_config=plotlyhtml._window_plotly_config,
              mathjax_config=plotlyhtml._mathjax_config,
              plotly_cdn=plotly_cdn_url().rstrip(".js"),
          )
      else:
          # If not connected then we embed a copy of the plotly.js library
          script = textwrap.dedent(
              """
              {win_config}
              {mathjax_config}
              <script type="text/javascript">
                  if (typeof require !== 'undefined') {{
                      require.undef("plotly");
                      define('plotly', function(require, exports, module) {{
                          {script}
                      }});
                      require(
                          ['plotly'],
                          function(Plotly) {{
                              window._Plotly = Plotly;
                              window.Plotly = Plotly;
                              console.log('Loaded plotly successfully');
                          }},
                          function() {{console.log('Failed to load plotly')}}
                      );
                  }} else {{
                      console.log('requirejs is not present');
                  }}
              </script>
          """
          )
          return script.format(
              script=get_plotlyjs(),
              win_config=plotlyhtml._window_plotly_config,
              mathjax_config=plotlyhtml._mathjax_config,
          )
  
imports: import io
  import json
  import textwrap
  import typing
  from contextlib import contextmanager
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pandas
  import plotly.io._html
  from ipywidgets import DOMWidget
  from jsonpickle.pickler import Pickler
  from pandas.io.formats.style import Styler
  from plotly.io._utils import plotly_cdn_url
  from plotly.offline.offline import get_plotlyjs
  from deepchecks.core import check_result
  from deepchecks.core import errors
  from deepchecks.utils.dataframes import hide_index_for_display, un_numpy
  from deepchecks.utils.html import linktag
  from deepchecks.utils.strings import truncate_string
label_desc: Use image node_id 8 for calling a global function with example usage: plotlyjs_script(connected) and returns: script, script