class_docstr: Registers a session with a Sherpa Study via the port of the database.
  
  This function is called from trial-scripts only.
  
  Attributes:
      host (str): the host that runs the database. Passed host, host set via
          environment variable or 'localhost' in that order.
      port (int): port that database is running on. Passed port, port set via
          environment variable or 27010 in that order.
class_docstr_tok: ["Registers","a","session","with","a","Sherpa","Study","via","the","port","of","the","database",".","This","function","is","called","from","trial-scripts","only",".","Attributes",":","host","(","str",")",":","the","host","that","runs","the","database",".","Passed","host",",","host","set","via","environment","variable","or","'localhost","'","in","that","order",".","port","(","int",")",":","port","that","database","is","running","on",".","Passed","port",",","port","set","via","environment","variable","or","27010","in","that","order","."]
docstr: Keras Callbacks to send metrics to SHERPA.
  
  Args:
      trial (sherpa.core.Trial): trial to send metrics for.
      objective_name (str): the name of the objective e.g. ``loss``,
          ``val_loss``, or any of the submitted metrics.
      context_names (list[str]): names of all other metrics to be
          monitored.
docstr_tok: ["Keras","Callbacks","to","send","metrics","to","SHERPA",".","Args",":","trial","(","sherpa.core.Trial",")",":","trial","to","send","metrics","for",".","objective_name","(","str",")",":","the","name","of","the","objective","e.g",".","``","loss","``",",","``","val_loss","``",",","or","any","of","the","submitted","metrics",".","context_names","(","list","[","str","]",")",":","names","of","all","other","metrics","to","be","monitored","."]
code: def keras_send_metrics(self, trial, objective_name, context_names=[]):
      """
      Keras Callbacks to send metrics to SHERPA.
  
      Args:
          trial (sherpa.core.Trial): trial to send metrics for.
          objective_name (str): the name of the objective e.g. ``loss``,
              ``val_loss``, or any of the submitted metrics.
          context_names (list[str]): names of all other metrics to be
              monitored.
      """
      import keras.callbacks
  
      send_call = lambda epoch, logs: self.send_metrics(
          trial=trial,
          iteration=epoch,
          objective=logs[objective_name],
          context={n: logs[n] for n in context_names},
      )
      return keras.callbacks.LambdaCallback(on_epoch_end=send_call)
  
imports: import logging
  import numpy
  import pymongo
  from pymongo import MongoClient
  import subprocess
  import time
  import os
  import socket
  import warnings
  import sherpa
label_desc: Use image node_id 4 for calling the Client obj's underlying member method code with example usage: obj.keras_send_metrics(trial, objective_name, context_names) and returns: keras